Restricting specific patch of road using overlays - here-api

I am trying to implement overlay in HERE map to restrict specific path of a road.
To achieve this i am referring to following guidelines:
https://developer.here.com/documentation/fleet-telematics/dev_guide/topics/custom-routes.html
The road which i am trying to restrict for routing is around 5km long.
Important thing over here is to get shape points in following format:
An array of shape points where each shape point is an array of two elements, latitude and longitude, in WGS-84 degrees. Currently, the first and last point must each fit within 5 meters tolerance onto existing links. These points must not both end up on the same link.
My basic question is how one can get shape points for desired route in above format.
I tried calculating route between 2 waypoints and added all shape points received by calculateroute response in upload.json request.
Request was successful although route never gets ignored.
Following are my route request parameters:
routeRequestParams = {
mode: 'fastest;car',
representation: 'display',
routeattributes : 'waypoints,summary,shape,legs',
maneuverattributes: 'direction,action',
waypoint0: '24.799113,46.867249',
waypoint1: '24.676569,46.641192',
overlays:'OVERLAYBLOCK11'
};
Kindly let me know what am i missing.
BR,
Harshal

Please use the following format to restrict or add any link in the overlay. Try your use case in our map and also share the entire request "https://tcs.ext.here.com/examples/v3/custom_routing_basic"
/2/overlays/upload.json
?map_name=OVERLAYBASICDEMO1&overlay_spec=
[{"op":"override",
"shape":[[50.10765,8.68774],[50.10914,8.68771]],
"layer":"LINK_ATTRIBUTE_FCn",
"data":{"VEHICLE_TYPES":"0"}},
{"op":"create",
"shape":[[50.10937,8.68422],[50.10807,8.68525],[50.10737,8.68387]],
"data":{"NAMES":"ENGBNDemo Road"}}]
&app_id=inCUge3uprAQEtRaruyaZ8&app_code=9Vyk_MElhgPCytA7z3iuPA
&storage=readonly
eg [{"op":"restrict","shape":[[53.54742,9.99704],[53.54746,9.99765]], "type":"preferred", "data":{"VEHICLE_TYPES":"145","PREFERRED_ROUTE_TYPE":"201","ENTRY_PENALTY":-1,"DRIVE_PENALTY":-0.1}}]

Related

Set current location in a route based on a arbitrary distance

I'm just playing around with Here and this is my escenario for an idea.
Get a routing between 2 points, I know this is doable
Set the start and finish marker, I know this is doable
Get the distance between the 2 points, I know this is doable
Now, if the distance from point 1 and 2 is 3000 meters I want to set a marker ( You are here ) based on a arbitrary distance value, let say I want to add a marker at the 1750 meters point, the market should appears in the half route way.
Is this posible with the actual API?
Thanks in advance!
Yes it is possible to do with HERE javascript API.
Once you get routing response and create H.geo.LineString out of it, you can calculate distance between each two geo points from that line string using H.geo.Point#distance method. This will help to determine between which two points (lat, lng) is your desired arbitrary distance.
After that you need to calculate angle between these two geo points and use it in method H.geo.Point#walk in order to get exact position of the geo point you need.
Here you can find jsfiddle example which places marker on the simple LineString based on desired arbitrary distance.

How the ADAS_ATTRIB attribute vertical_flags has to be interpreted

I'm playing a little with the route matching function of here api.
And I stumbled across an ADAS_ATTRIB attribute called VERTICAL_FLAGS.
The only time it's mentioned in the docs is (at least what I've found so far):
"Y/N. Specifies for each coordinate point along the link, whether it was introduced on a straight road section, because of height changes. If Y then this shape point exists only in the ADAS link gemoetry, but not in the standard road geometry."
Regarding this, how can a sample output like this:
"shape": "49.00027 12.12437 49.00024 12.12431 49.00002 12.12399",
"attributes": {
"ADAS_ATTRIB_FCN": [
{
"SLOPES": "[-86, 157, 60, -1]",
"CURVATURES": "[-3051, -1015]",
"HPZ": "[38522, 0, 3, 1]",
"VERTICAL_FLAGS": "[1, 0]"
}
]
},
be interpreted?
Each link(road) is represented as a polyline between two nodes in Here map data. This polyline contains one or more shapepoints which represent the shape of the link. Data is represented as different layers in the map (for ease of storage). The road topology layer data contains basic map data like links and nodes information(along with shape points). Shape points are points on a link which are introduced whenever there is a change in road goemetry, etc. In addition to the shape points present in road topology layer, ADAS layer might have introduced some more shape points in the same link for representing ADAS information(eg: road height change, curvature etc). VERTICAL_FLAGS represents whether the shape points found for a link in ADAS attribute is also present in topology segment or not.
You can read about the entire list of ADAS Attributes available here https://tcs.ext.here.com/pde/layer?region=WEU&release=18150&url_root=pde.api.here.com&layer=ADAS_ATTRIB_FC1 (login with Here credentials). Hope this helps!

is there a way to set heading for a Point?

I have heading that i get with this computeHeading(from:LatLng, to:LatLng), latlng of one point and distance to second point(in meters) is there a way using these three things to get latlng of second point ?
From google docs Navigation Functions
Given a particular heading, an origin location, and the distance to travel (in meters), you can calculate the destination coordinates using computeOffset().

Recalculate Google Maps Direction if take the wrong lane

I use the Google Maps Javascript API v3 for calculating the directions from my current position to my end destination in an iPad PhoneGap Application.
Now I want to make a function which automatically recalculates the directions, if you take the wrong lane. That means, I will make a marker for the current position on the map and then should check if it's near the directions-polygon, if not recalculate the route.
The directions are printed out in a canvas-element and I couldn't find anything how to compare it with my markers…
Any idea?
The following line works. Just set the tolerance as desired.
google.maps.geometry.poly.isLocationOnEdge (point, polyline, tolerance)
It will return true if point is located in the polyline/ polygen. Let me know if tyhis doesn't work.
axs

Google Maps API v3 Polylines not drawing

App works this way:
User enters a starting location and a distance. User can choose to draw circles, or lines over the roads. Circles work fine. Lines used to work.
When Lines, the code finds the lat/long of the starting location, then for the points N, S, E, W of the origin at the distance set by the user (say, 100km). Starting with the N destination, the code calls google.maps.DirectionsService() to get directions from the origin to N. This returns an array of lat/longs in the the route.overview_path.
NOTE: I COULD use the directionsRenderer() to draw the route, BUT, the distance drawn would be greater than the distance set by the user. Drawing the entire route from the origin to the point N might be 124km over the roads, and I just want to draw 100km.
Instead, I step through the route.overview_path[] array, checking the distance between that point and the point of origin, adding each point to a new array. When the distance is greater than the dist set by the user, I stop, pop off the last element, then create a new Polyline based on this 2nd, smaller array.
I've spent the entire day in Chrome's developer mode walking through the javascript, setting breakpoints, watching locals, etc. The array of points passed in google.maps.Polyline({}) is a good array of unique points. I just cannot figure out why they aren't rendering.
Ultimately, the code used to draw 4 lines starting at the point of origin, one heading North, one heading East, South, West. etc....
The code is here: http://whosquick.com/RunViz.html
Thank you for your attention.
Nevermind. Solved it.
var objGeo = new LatLon(Geo.parseDMS(myroute.overview_path[0].Pa), Geo.parseDMS(myroute.overview_path[0].Qa));
I had inadvertently switched Pa with Qa.

Resources