1

I'm following the pgrouting-workshop http://workshop.pgrouting.org/chapters/topology.html and It works, but in my project I'm working with the mercator projection(srid 3785) and there is not a routed network like the Open Street Map to work in, so I need to build my own.. so for testing purposes with the help of google maps and Proj4js I build a simple graph like this

enter image description here

point1 = "POINT (-7363703.972517611 -1966750.4952863816)"
point2 = "POINT (-7363530.794875402 -1966719.4427436402)"
point3 = "POINT (-7363414.945004408 -1966694.3618437336)"
point4 = "POINT (-7363365.977533163 -1966681.2242294976)"
point5 = "POINT (-7363419.722318676 -1966658.5319867264)"
point6 = "POINT (-7363344.479618957 -1966793.4911147922)"
// it's in lon / lat format

Then the geom column in ways table
way_red = "MULTILINESTRING((point1, point2, point3, point4))"
way_green = "MULTILINESTRING((point3, point5))"
way_blue = "MULTILINESTRING((point4, point6))"

Questions:

  1. Is it correct the format I builded the ways ??
  2. Exist a correct or pre-established format to construct a routeable network?
  3. the workshop uses "MULTILINESTRING", is it ok if I use just "LINESTRING"??

Thanks in advance, and sorry for my english.

2 Answers 2

4

1) Is it correct the format I builded the ways ??

Not quite. The red way has to be split at point 3. Ways have to be split at each intersection if turning should be possible there.

Also the point coordinates you specified cannot be valid latitudes/longitudes.

2) Exist a correct or pre-established format to construct a routeable network?

You generally need a source node id (or "from_node") and a target node id (or "to_node") plus some edge weight (can be length/distance or travel time or energy cost). Some algorithms will also use the actual geometry (MULTI/LINESTRING) but basic shortest path doesn't.

3) the workshop uses "MULTILINESTRING", is it ok if I use just "LINESTRING"??

That's fine. You shouldn't encounter multilinestrings in routing graphs anyway.

2
  • Thanks for your answers but I have another question... why do u say the format of the point coordenates isn't valid?? I was reading in this forum and it says that the correct form of introduce the data is in lon(x)/lat(y), although generally data is shown in lat/lon, and I'm using the proj4js becouse I need the data in EPSG 3785 google mercator. EPSG 3785 : (-7363703.972517611, -1966750.4952863816) = EPSG 4326: (-66.14927826244207, -17.394110572053894).. thats correct, right ?? Jun 27, 2012 at 16:14
  • The points are specified as x/y in meters for EPSG3785. Lat/lon implies that you'd be using degrees.
    – underdark
    Jun 27, 2012 at 16:41
1
  1. Is it correct the format I builded the ways ?
  2. Exist a correct or pre-established format to construct a routeable network?

If your network data is not OSM data and it doesn't contain information about source and target of each road segment, then you can use the assign_vertex_id function to prepare your data for routing. See: http://workshop.pgrouting.org/chapters/topology.html#calculate-topology

If your data is in a different projection than you need, you can use ST_transform to re-project into the SRID you need: http://postgis.net/docs/ST_Transform.html

  1. the workshop uses "MULTILINESTRING", is it ok if I use just "LINESTRING"?

Yes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.