A
A
Alexander Smagin2021-09-10 11:00:52
C++ / C#
Alexander Smagin, 2021-09-10 11:00:52

What is the best way to implement the following task in C#?

Good afternoon.
There is a certain cartographic product and API for writing your desktop application.
A map is created on which some objects are applied from an external data source (DB). Objects are stored in the map as in the database.
Information on the map should be updated every 1 second.
Question: How to update the data on the map when the data (coordinates of objects) in the external database changes? Objects can have both immutable and mutable data. For example, the car changed direction or speed.
I assumed that it was possible to form some initial State to update it from the database, and then update the map using events. But I'm not sure if this is the best solution.
I understand that the question is too abstract, but maybe someone has solved similar problems and will tell you their approach. Maybe some pattern to use?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
oleg_ods, 2021-09-10
@oleg_ods

Objects are stored in the map as in the database.

Objects are not stored on the map, they are displayed on it.
Objects can have both immutable and mutable data. For example, the car changed direction or speed.

From the point of view of geolocation, the object from the changeable data has only coordinates, and based on the previous coordinates and the current one, you can calculate the direction and speed of movement.
Information on the map should be updated every 1 second.

Are you sure that you need such a frequency of updates? How often will coordinates be updated in the database? What is the average speed of the objects? What is the accuracy of GPS sensors?
Otherwise, any mapping API with support for setting your own markers will suit you. For example, Google maps.

A
Alexander Smagin, 2021-09-10
@Paxorin

Objects are not stored on the map, they are displayed on it.

Since in my case this is a specific product (GIS Panorama), then there user vector maps are implemented as a repository of objects. Objects are saved by committing to a map. That is, you can create an object on the map (for example, a communication node), close-open the map, it is displayed again. But this is not so important for the question.
From the point of view of geolocation, the object from the changeable data has only coordinates, and based on the previous coordinates and the current one, you can calculate the direction and speed of movement.

car as an example. This may be a radar station, which changes the azimuth of the zone of responsibility or coordinates. And for example, the range of the zone of responsibility is always the same.

Are you sure that you need such a frequency of updates? How often will coordinates be updated in the database? What is the average speed of the objects? What is the accuracy of GPS sensors?

Not sure. 1 sec example. Let it be 5 seconds.
I'm more interested in how to generally implement updating a map from a database. Those. I have to poll the database every five seconds, somehow compare the new data with the old ones, and if something has changed, somehow notify the card that new data needs to be drawn. In the current API, it is not very convenient to query the map about the available objects for comparison with the database. There must be some kind of intermediate storage, some kind of state. How to organize this state? List of objects?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question