There is currently a Shapefile file containing *. DBF, *. SHP, *. SHX, I want to know how to extract road network information to achieve path planning.
Can you help me?
Thank you very much!
There is currently a Shapefile file containing *. DBF, *. SHP, *. SHX, I want to know how to extract road network information to achieve path planning.
Can you help me?
Thank you very much!
MapWinGIS does have a Network option: ShapeNetwork Class
I havenāt used it even and Iām not sure if it is still working as expected.
An alternative could be to use pgRouting and PostGIS. MapWinGIS can connect to a PostGIS db.
A good article about pgRouting can be found at Getting Started with pgRouting in PostGIS
Additionally, the open-source library Itinero, is capable of building/using Shapefiles as street networks for routing.
How to connect to a PostGIS db ? Can you give me some advice?
Thanks.
Hereās some documentation with sample code:
https://www.mapwindow.org/documentation/mapwingis4.9/class_ogr_layer.html#details
Excuse me, Iām still a little confused.
I want to implement this function that opens a Road network layer file (road.shp) on MapWinGis, gets the longitude and latitude of the starting and target points with the mouse, makes path planning, and displays the navigation path on MapWinGis.
Can you give me some detailed implementation steps?
Thank you very much!
Iām sorry, @Jackson, for any confusion.
What youāre looking for is not a function of MapWinGIS. There are a variety of Routing libraries out there, although many of them use OpenStreetMaps as their road network.
@pmeems previously made reference to the pgRouting library, but I believe that expects the road network to be stored in PostGIS as opposed to Shapefiles.
I have used the Itinero library, since it supports Shapefiles, and you are able to display the results as a layer in MapWinGIS. Note that this is not a trivial task; there is a bit of groundwork to be done to make it work. Using the Itinero library, I had to write a custom program to generate the Street Network from the Shapefile.
Does this help clarify things?
What should I do if Iām using the Itinero library in MFC?Do you have a few examples of the Itinero library?
Sorry to bother you again!
As a start, there is a document that I submitted to the Itinero group, documenting some of the aspects of creating and generating routes from Shapefiles. It is in c#, but hopefully it helps some.
I couldnāt figure out how to attach the document, but if you follow this link, on my comment dated Jan 29, 2018, you will find a link to the document.
Regards.
Jerry.
I generated a path with PostGis+pgRouting, and I wanted to know how to display this path as a layer in MapWinGIs.
I hope you can help me.
Thank you very much!
Forgive me for asking, but are you the same @Jackson as JackSon-XI on the Itinero site. Iām wondering if Iām having two conversations with the same person (using MFC, implementing routing in MapWinGIS). Or is it just an amazing coincidence?
Regarding PostGis+pgRouting, how are the results stored? in a āGeometryā field in the database, or as a collection of Points? Either way, you should be able to use the MapWinGIS/OGR connection to PostGis to open the table, and get the data. If already a āgeometryā, then you should be able to add the route results an an OGR Layer in MapWinGIS. If something like a Point collection, then you could build the routes in a Polyline Shapefile layer in MapWinGIS. Are any/all of your other layers coming from PostGis? or is it only the routing results?
Thank you very much for your reply! Itās my pleasure! Yes, we are the same person.
I have another question to consult you.My specific ideas are as follows:
In the first step, MapWinGIS connects to PostGis and imports a road network Shapefile file into it.
In the second step, click two points (the starting point and the target point) on MapWinGIS and pass it to PostGis.
Third, can you use C++ operations on pgRouting to implement path planning and generate a routing layer or is there another way?
Fourth, add the layer to MapWinGIS.
I hope you can give me some advice!
thank you
I think your logic is correct. What I donāt know off-hand is on the third step, how pgRouting provides the results. It may not be a layer, but instead a polyline geometry that you add to your own layer. Thatās what I have to do with Itinero.
While weāre talking, I have a question for you, regarding MFC. I was recently tasked with providing map support within an MFC application. After adding the OCX, and assigning it to a variable, I am able to make any calls into the Map control itself (internally, the _DMap Interface). However, when attempting to instantiate any other objects (e.g. Extents, or GlobalSettings), it works on the development machine, but always gets a Library Not Registered on a non-development machine. The map functions work, but the other classes donāt.
Something like the following:
CGlobalSettings* gs = new CGlobalSettings();
gs->CreateDispatch("MapWinGIS.GlobalSettings");
gs->put_ReprojectLayersOnAdding(TRUE);
gs->ReleaseDispatch();
delete gs;
The call to ReprojectLayersOnAdding is the line that errors out on the other machine. Any ideas? Have you been able to successfully interact with the non-Map classes?
Thanks for any input. And Iāll continue to be whatever help I can on the routing.
Regards.
Jerry.
Have you solved the problem? Iām sorry, Iāve never used this before, but Iād love to think about it.
What does the CGlobalSettings class do and from which class does it inherit?
The MapWinGIS.ocx contains the Map control itself, plus a whole set of support objects (including Shape, Point, Layer, GlobalOptions, etc.). In the MFC application, you can add any of these classes through the Class Wizard, through the Add Class from TypeLib options.
These classes are added as CShape, CPoint, CGlobalOptions, etc, each derived from COleDispatchDriver. You can then create these, associate them with a pointer to an instance (LPDISPATCH) by calling, for example,
CGlobalOptions* pGlobalOptions = new CGlobalOptions();
pGlobalOptions->CreateDispatch("MapWinGIS.GlobalOptions");
All of this works on the development machine, but gets a āLibrary Not Registeredā (or similar) error on a non-development machine as soon as you try to call any method on this object. The map control works everywhere, but the support classes (anything that is not part of the Map interface) does not work.
I tested it and I have a question.The following code:
CGlobalSettings* gs = new CGlobalSettings();
gs->CreateDispatch("MapWinGIS.GlobalSettings");
gs->put_ReprojectLayersOnAdding(TRUE);
gs->ReleaseDispatch();
delete gs;
Among them,
Put_ReprojectLayersOnAdding
is not a member function of CGlobalSettings
, so it would give an error!
This thread has multiple questions.
Is the original question about the path planning enough answered?
And the last question about Put_ReprojectLayersOnAdding
? If not, that question is better of in its own thread.
Thanks @Jackson, I should have followed up on this earlier.
There is a property ReprojectLayersOnAdding, which through c++ is exposed as put_ReprojectLayersOnAdding. I have noticed that, when importing the TypeLib through Visual Studio, it does not always generate a stub for every method, and sometimes Iāve had to add them manually. Perhaps thatās happened in your environment.