How to implement path planning

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.

1 Like

How to connect to a PostGIS db ? Can you give me some advice?

Here’s some documentation with sample code:

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.


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.

  1. I let MFC generate a Class based on the Type Library
  2. I create the object
  3. I call CreateDispatch on the object, passing in the progID (e.g. “MapWinGIS.GlobalSettings”)
  4. I can then make any calls while working on the development maching, but as soon as I put the executable on another machine, even though MapWinGIS is installed/registered, and I can interact with the map, any of the calls into the other classes raises an error. It is able to create the object, but all methods fail.

Something like the following:

CGlobalSettings* gs = new CGlobalSettings();
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.


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();

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();
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.