How the ADAS_ATTRIB attribute vertical_flags has to be interpreted - here-api

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!

Related

Is it possible to retrieve beam real world position from RT PLAN

I am currently working on some radiotherapy plan generation and I am trying to retrieve the beam source position from a DICOM RTPLAN file and point it on a related CT-Scan 3D image.
With the RTPLAN, I am able to access the isocenter position of each beam but this is in patient coordinates and I am note quite sure how to find the coordinates in the basis that is used by the 3D CT-Scan image.
I have access to the attributes ImagePosition and ImageOrientation of the DICOM of the CT. Moreover, the CT DICOM-like file (it is in practice a json regrouping some DICOM information) and the RTPLAN share the same FrameOfReference (Does it mean that they share the Patient coordinate system ?).
What does ImagePosition truely indicates ? As well as I can understand I think this is the position of the point (0, 0, 0) of the CT-3DImage in the Patient Coordinates. I am also a bit confused about the ImageOrientation attribute.
As you can read in this answer here, the ImagePosition attribute gives you the x, y, and z coordinates of the upper left hand corner of the image, in mm, i.e. the coordinates of the center of the upper left pixel of the image.
For your convenience I copy-paste below a table from the DICOM Documentation Part 3 (page 561).
Regarding the ImageOrientation attribute, as described in the documentation, gives you the direction cosines of the first row and the first column with respect​ to the patient. To understand better this attribute take a look at the very useful website, DICOM is Easy, by Roni Zaharia. In one of his images (below), you can clearly see that when the attribute is not equal to 1\0\0\0\1\0, then the coordinate system of the image is not align with the coordinate system of the patient. To align them, you have to use the direction cosines provided by the attribute and apply a rotation (take a look at the transformation matrix at page 562 of the aforementioned DICOM documentation).

Restricting specific patch of road using overlays

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}}]

How does a non-tile based map works?

Ok, here is the thing. Recently i decided i wanted to understand how Random map generation works. I found some papers and some arguments. The most interesting one was "Diamond Square algorithm" and "Midpoint Displacement". I still have to try to apply those to a software, but other than that, i ran into this site: http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/
As you can see, the idea is to use polygons. But i have no idea how to apply that a Tile-Based map, not even how to create those polygons using the tools i have (c++ and sdl). I am assuming there is no way to do it ( please correct me if i am wrong.) But if i am not, how does a non-tile map works, and how are these polygons generated?
This answer will not give you directly the answers you're looking for, but hopefully will get you close enough!
The Problem
I think what blocks you is how to represent the data. You're probably used to a 2D grid that simply represent the type of each tile. As you know, this is fine to handle a tile-based map, but doesn't properly allow you to model worlds where tiles are of a different shape.
Graphs
What I suggest to you, is to see the problem a bit differently. A grid is nothing more than a graph (more info) with nodes that have 4 (or 8 if you allow diagonals) implicit neighbor nodes. So first, what I would do if I was you, would be to move from your strict standard 2D grid to a more "loose" graph, where each node has a position, a position, a list of neighbors (in most cases you'll have corners with 2 neighbors, borders with 3 and "middle" tiles with 4) and finally a rendering component which simply draws your tile on screen at the given position. Once this is done, you should be able to have the exact same results on screen that you currently have with your "2D Tile-Based" engine by simply calling the rendering component with each node who's bounding box (didn't touch it in what you should add to your node, but I'll get back to this later) intersects with the camera's frustum (in a 2D world, it would most likely if the position +/- the size intersects the RECT currently being drawn).
Search
The more generic approach will also help you doing stuff like pathfinding with generic algorithms that explore nodes until they find a valid path (see A* or Dijkstra). Even if you decided to stick to a good old 2D Tile Map game, these techniques would still be useful!
Yeah but I want Polygons
I hear you! So, if you want polygons, basically all you need to do, is add to your nodes a list of vertices and the appropriate data that you might need to render your polygons (either vertex color, textures and U/V maps, etc...) and update your rendering component to do the appropriate OpenGL (this for example should help) calls to draw your nodes. Once again, the first step to iteratively upgrade your 2D Tile Engine to a polygon map engine would be to, for each tile in your map, give each of your nodes two triangles, a texture resource (the tile), and U/V mappings (0,0 - 0,1 - 1,0 and 1,1). Once again, when this step is done, you should have a "generic" polygon based tile map engine. The creation of most of this data can be created procedurally by calculating coordinates based on tile position, tile size, etc...
Convex Polygons
If you decide that you ever might need NPCs to navigate on your map or want to allow your player to navigate by clicking the map, I would suggest that you always use convex polygons (the triangle being the simplest for of a convex polygon). This allows your code that assume that two different positions on the same polygon can be navigated to in straight line.
Complex Maps
Based on the link you provided, you want to have rather complex maps. In this case, the author used Voronoi Diagrams to generate the polygons of the map. There are already solutions to do triangulation like that, but you might also want to use other techniques that are easier to work with if you're just switching to 3D like this one for example. Once you have interesting results, you should consider implementing serialization to save/open your map data from the game. If you want to create an editor, be aware that it might be a lot of work but can be worth it if you want people to help you creating maps or to add elements to the maps (like geometry that's not part of the terrain).
I went all over the place with this answer, but hopefully it helps!
Just iterate over all the tiles, and do a hit-test from the centre of the tile to the polys. Turn the type of the tile into the type of the polygon. Did you need more than that?
EDIT: Sorry, I realize that probably isn't helpful. Playing with procedural algorithms can be fun and profitable. Start with a loop that iterates over all tiles and chooses randomly whether or not the tile is occupied. Then, iterate over them again and choose whether it is occupied or its neighbour is.
Also, check out the source code for this: http://dustinfreeman.org/toys/wall7-dustin.html

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.

Generating a 3D prism from any 2D polygon

I am creating a 2D sprite game in Unity, which is a 3D game development environment.
I have constrained all translation of objects to the XY-plane and rotation to the Z-axis.
My problem is that the meshes that are used to detect collisions between objects must still be in 3D. I have the need to detect collisions between the player object (a capsule collider) and a sprite (that has its collision volume defined by a polygonal prism).
I am currently writing the level editor and I have the need to let the user define the collision area for any given tile. In the image below the user clicks the points P1, P2, P3, P4 in that order.
Obviously the points join up to form a quadrilateral. This is the collision area I want, however I must then convert that to a 3D mesh. Basically I need to generate an extrusion of the polygon, then assign the vertex winding and triangles etc. The vertex positions is not a problem to figure out as it is merely a translation of the polygon down the z-axis.
I am having trouble creating an algorithm for assigning the winding order of the vertices, especially since the mesh must consist only of triangles.
Obviously the structure I have illustrated is not important, the polygon may be any 2d shape and will always need to form a prism.
Does anyone know any methods for this?
Thank you all very much for your time.
A simple algorithm that comes to mind is something like this:
extrudedNormal = faceNormal.multiplyScale(sizeOfExtrusion);//multiply the face normal by the extrusion amt. = move along normal
for each(vertex in face){
vPrime = vertex.clone();//copy the position of each vertex to a new object to be modified later
vPrime.addSelf(extrudedNormal);//add translation in the direction of the normal, with the amt. used in the
}
So the idea is basic:
clone the face normal and move it in
the same direction by the amt. you
want to extrude by
clone the face vertices and move them
using the moved(extruded) normal
position
For a more complete, feature rich example, refer to the Procedural Modeling Unity samples. They include a nice Mesh extrusion sample too (see ExtrudedMeshTrail.js which uses MeshExtrusion.cs).
Goodluck!
To create the extruded walls:
For each vertex a (with coordinates ax, ay) in your polygon:
- call the next vertex 'b' (with coordinates bx, by)
- create the extruded rectangle corresponding to the line from 'a' to 'b':
- The rectangle has vertices (ax,ay,z0), (ax,ay,z1), (bx,by,z0), (bx,by,z1)
- This rectangle can be created from two triangles:
- (ax,ay,z0), (ax,ay,z1), (bx,by,z0) and (ax,ay,z1), (bx,by,z0), (bx,by,z1)
If you want to create a triangle strip instead, it's even simpler. For each vertex a, just add (ax,ay,z0) and (ax,ay,z1). Whichever vertex you processed first will also need to be processed again after looping over all other vertices.
To create the end-caps:
This step is probably unnecessary for collision purposes. But, one simple technique is here: http://www.siggraph.org/education/materials/HyperGraph/scanline/outprims/polygon1.htm
Each resulting triangle should be added at depth z0 and z1.

Resources