[OSRM-talk] Bearings and bearings range

2015-10-24 Thread Fernando Pacheco
We have been using OSRM (vrptools software) to optimize collection 
routes of solid waste (basically viaroute and nearest plugins).


At the moment we are implementing container collection by the right side 
(some types of containers must be collected by the right side of the 
truck), so the bearing parameter has been very useful.


We don't know street bearing, so the direction of the truck to pick up 
the container is obtained from the location of the container and the 
location of the PhantomNode (+90 degrees).


We have slightly changed the code OSRM to be more flexible in this case. 
In particular we have:
* added custom bearings range parameter for viaroute (bearings_range in 
route_parameters and bs_range in api_grammar). [8 degrees is not enought 
in some cases (containers located very near of an edge)];
* added bearing = -1 when we do not want to take account bearing 
parameter in a route point  (not necessary for us in one-way streets).


I attach the patch file in case it is useful. Thank you for all!. Best 
regards. Fernando.diff --git a/data_structures/route_parameters.cpp b/data_structures/route_parameters.cpp
index ad01340..b710eb5 100644
--- a/data_structures/route_parameters.cpp
+++ b/data_structures/route_parameters.cpp
@@ -122,7 +122,7 @@ void RouteParameters::addBearing(const int bearing, boost::spirit::qi::unused_ty
 {
 bearings.resize(coordinates.size());
 pass = false;
-if (bearing < 0 || bearing > 359) return;
+if (bearing < -1 || bearing > 359) return;
 if (!bearings.empty())
 {
 bearings.back() = bearing;
@@ -130,6 +130,14 @@ void RouteParameters::addBearing(const int bearing, boost::spirit::qi::unused_ty
 }
 }
 
+void RouteParameters::setBearingsRange(const int range)
+{
+  if ( range>0 && range<=90 )
+  {
+bearings_range = range;
+  }
+}
+
 void RouteParameters::setLanguage(const std::string _string)
 {
 language = language_string;
diff --git a/include/osrm/route_parameters.hpp b/include/osrm/route_parameters.hpp
index f49d440..fcef515 100644
--- a/include/osrm/route_parameters.hpp
+++ b/include/osrm/route_parameters.hpp
@@ -72,7 +72,9 @@ struct RouteParameters
 
 void addTimestamp(const unsigned timestamp);
 
-void addBearing(const int timestamp, boost::spirit::qi::unused_type unused, bool& pass);
+void addBearing(const int bearing, boost::spirit::qi::unused_type unused, bool& pass);
+
+void setBearingsRange(const int range);
 
 void setLanguage(const std::string );
 
@@ -103,6 +105,7 @@ struct RouteParameters
 std::vector hints;
 std::vector timestamps;
 std::vector bearings;
+int bearings_range;
 std::vector uturns;
 std::vector coordinates;
 };
diff --git a/plugins/match.hpp b/plugins/match.hpp
index 55a8c14..c7530bb 100644
--- a/plugins/match.hpp
+++ b/plugins/match.hpp
@@ -95,6 +95,7 @@ template  class MapMatchingPlugin : public BasePlugin
 
 bool getCandidates(const std::vector _coords,
   const std::vector _bearings,
+  const int input_bearings_range,
   const double gps_precision,
   std::vector _trace_lengths,
   osrm::matching::CandidateLists _lists)
@@ -102,6 +103,14 @@ template  class MapMatchingPlugin : public BasePlugin
 double query_radius = 10 * gps_precision;
 double last_distance = coordinate_calculation::great_circle_distance(input_coords[0], input_coords[1]);
 
+int bearing = 0;
+int range = 180;
+int bearings_range = 10;
+if (input_bearings.size() > 0 )
+{
+bearings_range = (input_bearings_range > 0 && input_bearings_range < 90) ? input_bearings_range : 10;
+}
+
 sub_trace_lengths.resize(input_coords.size());
 sub_trace_lengths[0] = 0;
 for (const auto current_coordinate : osrm::irange(0, input_coords.size()))
@@ -128,10 +137,19 @@ template  class MapMatchingPlugin : public BasePlugin
 }
 }
 
-std::vector> candidates;
 // Use bearing values if supplied, otherwise fallback to 0,180 defaults
-auto bearing = input_bearings.size() > 0 ? input_bearings[current_coordinate] : 0;
-auto range = input_bearings.size() > 0 ? 10 : 180;
+if (input_bearings.size() > 0 && input_bearings[current_coordinate] != -1)
+{
+bearing = input_bearings[current_coordinate];
+range = bearings_range;
+}
+else
+{
+bearing = 0;
+range = 180;
+}
+
+std::vector> candidates;
 facade->IncrementalFindPhantomNodeForCoordinateWithMaxDistance(
 input_coords[current_coordinate], candidates, query_radius,
 bearing, range);
@@ -304,7 +322,7 @@ template  class MapMatchingPlugin : 

Re: [OSRM-talk] finds routes with arrivals from the right

2015-04-22 Thread Fernando Pacheco
First, I answer myself: The PhantomNode structure elements
(forward_node_id, reverse_node_id, etc) are set in different
methods/functions in StaticRTree class and are very similar to
EdgeBasedNode structure.

The ids of nodes in EdgeBasedNode structure are different from internal
nodes ids (OSRM).

The EdegeBasedNode structure have u and v elements, that are the indices
of internal nodes (OSRM id). With them, you can find the coordinates of
each node of the segment and / or the original node id (OSM id).

The PhantomNode structure do not have u and v elements (why?).

Then, what is the best way to get the internal id (OSRM) from
forward_node_id and reverse_node_id of each PhantomNode?.

Thanks. Fernando.

El 12/04/15 a las 18:47, Fernando Pacheco escribió:
 I'm trying to make a plugin that finds routes with arrivals from the
 right on two-way streets (to collect municipal solid waste containers).
 I clone the viaroute plugin and made changes to suit my needs.
 
 I have one starting point, many pick up points (containers) and one
 ending point. Some trucks can just pick up containers from the right.
 
 Basically what I want to do is add an intermediate point in the adequate
 direction (in two-ways streets) to force the vehicle to flow in the
 desire direction.
 
 I need to get (from the plugin) node coordinates in front and behind the
 segment in which the lifting point.
 
 I can get the coordinates of phantomnode (location) and forward_node_id
 and reverse_node_id but these identifiers are not allowing me to get
 those coordinates. I think is_bidirected() telling me if the the way
 segment is two-way.
 
 I am somewhat confused because in all cases packed_geometry_id gives me
 maximum unsigned limit values. I had thought that with that identifier I
 would obtain the segment and then the geometry nodes where the phantom
 node is.
 
 I am working with the develop branch.
 
 Could you give me some hints?
 
 How can I get the coordinates of the nodes of the segment where the
 phantomnode is?
 
 I'm in the wrong direction?. Many thanks. Fernando.

-- 
Ing. Fernando Pacheco M.S.L.

Ingesur srl
Dirección: Reconquista 268 apto. 511, Montevideo, Uruguay.
Teléfonos: +598 29161459, +598 99627932
Web: http://www.ingesur.com.uy/

___
OSRM-talk mailing list
OSRM-talk@openstreetmap.org
https://lists.openstreetmap.org/listinfo/osrm-talk


Re: [OSRM-talk] Can hints be used to identify a common segment?

2015-04-21 Thread Fernando Pacheco
If points are not in order in the route, but are in the same segment,
then forward_node_id, reverse_node_id and name_id for each phantom node
must be identical. As you say, this information is already in hint_data
(decriptors/json_descriptors.hpp). Best regards. Fernando.

El 21/04/15 a las 10:33, Stephen Woodbridge escribió:
 Hi Fernando,
 
 Thank you that is a useful observation but my problem is a little
 different. I have many positions and I would like to determine those
 that lie on the same segment so that I can group them together.
 
 If I remember correctly the hint is a base64 encoded pointer to the edge
 plus something like and offset along the edge. I could be useful to take
 advantage of this information to group and order locations along a path.
 
 I'll see if I can figure it out from the source code.
 
 -Steve
 
 On 4/21/2015 8:28 AM, Fernando Pacheco wrote:
 If both points are in the same segment, their position (third element in
 route_instructions) should be consecutive.

 Located on the same street but in different segments (3 and 5):
 [9, General José Esteban Brito del Pino 122,3,14, 121m, S, 193.1]
 [9, General José Esteban Brito del Pino, 57,5,21, 56m, S, 191.1]

 In the same segment (4 and 5):
 [9, General José Esteban Brito del Pino, 35,4,5, 34m, S, 191.1]
 [9, General José Esteban Brito del Pino, 56,5,21, 56m, S, 190.1]

 May be?. Fernando.

 El 21/04/15 a las 00:24, Stephen Woodbridge escribió:
 Hi,

 I have a need to be able to identify if two locations are on the same
 segment. We already have the hints for each location and there seems to
 be some commonality in the hints for location on the same segment.

 I'm wondering if there is a safe way to use the hints to determine if
 they are on the same segment.

 Thanks,
-Steve

 ---
 This email has been checked for viruses by Avast antivirus software.
 http://www.avast.com


 ___
 OSRM-talk mailing list
 OSRM-talk@openstreetmap.org
 https://lists.openstreetmap.org/listinfo/osrm-talk

 
 
 ---
 This email has been checked for viruses by Avast antivirus software.
 http://www.avast.com
 
 
 ___
 OSRM-talk mailing list
 OSRM-talk@openstreetmap.org
 https://lists.openstreetmap.org/listinfo/osrm-talk

-- 
Ing. Fernando Pacheco M.S.L.

Ingesur srl
Dirección: Reconquista 268 apto. 511, Montevideo, Uruguay.
Teléfonos: +598 29161459, +598 99627932
Web: http://www.ingesur.com.uy/

___
OSRM-talk mailing list
OSRM-talk@openstreetmap.org
https://lists.openstreetmap.org/listinfo/osrm-talk


[OSRM-talk] finds routes with arrivals from the right

2015-04-12 Thread Fernando Pacheco
I'm trying to make a plugin that finds routes with arrivals from the 
right on two-way streets (to collect municipal solid waste containers). 
I clone the viaroute plugin and made changes to suit my needs.


I have one starting point, many pick up points (containers) and one 
ending point. Some trucks can just pick up containers from the right.


Basically what I want to do is add an intermediate point in the adequate 
direction (in two-ways streets) to force the vehicle to flow in the 
desire direction.


I need to get (from the plugin) node coordinates in front and behind the 
segment in which the lifting point.


I can get the coordinates of phantomnode (location) and forward_node_id 
and reverse_node_id but these identifiers are not allowing me to get 
those coordinates. I think is_bidirected() telling me if the the way 
segment is two-way.


I am somewhat confused because in all cases packed_geometry_id gives me 
maximum unsigned limit values. I had thought that with that identifier I 
would obtain the segment and then the geometry nodes where the phantom 
node is.


I am working with the develop branch.

Could you give me some hints?

How can I get the coordinates of the nodes of the segment where the 
phantomnode is?


I'm in the wrong direction?. Many thanks. Fernando.

___
OSRM-talk mailing list
OSRM-talk@openstreetmap.org
https://lists.openstreetmap.org/listinfo/osrm-talk


[OSRM-talk] arrive to destination on the adequate side in two-way streets

2015-03-09 Thread Fernando Pacheco
Hi all.

We are developing an application for routing solid waste collection
trucks. We use OSRM to calculate distances between collecting points
(intermediate points).

Some customers are located in two-way streets (simple, no separators)
... How can I say to OSRM that must arrive to the collecting points at
the adequate side of the street? That is, on the side where the client
is, without crossing the opposite direction of the street to access the
load.

Is it possible?. Thanks in advance. Fernando.

-- 
Ing. Fernando Pacheco M.S.L.

Ingesur srl
Dirección: Reconquista 268 apto. 511, Montevideo, Uruguay.
Teléfonos: +598 29161459, +598 99627932
Web: http://www.ingesur.com.uy/

___
OSRM-talk mailing list
OSRM-talk@openstreetmap.org
https://lists.openstreetmap.org/listinfo/osrm-talk