There are two lists of Coordinates that represent the car path. I must determinate if these lists are opposed ( the direction of car ara opposed).
Anyone can suggest me one method?
Related
I think i have a difficult problem right here..
I want to able to get the surfaces of f.e. the orange object in this three.js example https://threejs.org/examples/?q=stl#webgl_loader_stl
i want to click with the mouse, find the correct surface, which should then be highlighted, so i make sure this was the surface i want.
(i already implemented raycaster successfully, so thats not an issue)
The intersectObject method returns an array of intersections, each of which has face property. The face contains vertex indices.
For STL files containing multiple solids, each solid is assigned to a different group, and the groups are available in the geometry object that is returned from STLLoader. Each group is defined by a range of vertex indices.
So, I think you can correlate the vertex indices returned from the raycaster with the vertex indices in the geometry groups.
I have two data layers, one with points and one with polygons. Both layers have ID's and I would like to check whether the points with ID x lay inside or outside the polygon with ID x.
Does someone know how to do this?
Thanks,
Marie
One potential solution which gives you a comma separated list in the python console is to run a small script from the python console:
mapcanvas = iface.mapCanvas()
layers = mapcanvas.layers()
for a in layers[0].getFeatures():
for b in layers[1].getFeatures():
if a.geometry().intersects(b.geometry()):
print a.id(),",",b.id()
This should produce a result of cases where one feature intersects the other. The order of the layers did not matter in my testing, however, both layers had to use the same coordinate reference system, so you might need to re-project your data if both layers have different reference systems. This worked for points in polygons and polygons intersecting polygons (I'm sure it would work with lines as well).
Answers such as this: https://gis.stackexchange.com/questions/168266/pyqgis-a-geometry-intersectsb-geometry-wouldnt-find-any-intersections may help with further refinement of such a script, and was a primary source on this answer.
I have a landscape with several habitats (i.e. polygons with different IDs). Each polygon of habitat is composed of several patches. In addition, each polygon of habitat has an associated cost. I would like to obtain the least cost path between the polygon that contains a turtle and all the polygons that are in buffer of 2 km around the polygon that contains a turtle.
In a first time, I think to use "weighted-distance-to" from NW extension. According to the example associated to this primitive, I should create a link between the polygon that contains a turtle and all the polygons that are in buffer of 2 km, then I should assign a weight value to the link. In the example, each link between two turtles is assigned to one weight value defined by user. In my case, as a link crosses different habitats, is it possible to calculate a weight value equal to cumulative costs along path towards one of polygons that are in buffer of 2 km ?
Thank you very much for your help.
Sound like you could create a cool variant of Dijkstra's shortest path algorithm.
http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
If you keep all generated paths in a TreeSet sorted on length, you pull the current shortest path, extend it with all possible polygons that have not been visited yet, and push these solutions in your TreeSet. If from a polygon you can only move to surrounding polygons at greater or equal costs than the shortest route you found so far you can drop that route. That way you expand only the shortest routes generating a breadth first search for the nearest turtle, while truncating possibilities that will never work.
good luck!
If I have two shapes displayed on Bing-Maps can I do any set Math?
What I really want is to take two intersecting shapes, determine a 3rd shape for the intersection and then reduce the the original shapes to exclude the intersection.
I actually have the intersection shape so the key bit is taking a 'bite' out of the original shapes.
Reason for doing this is currently displaying the intersection as a third layer (to give a specific colour) produces a largely occluded map, what with part of the transparent shape1 and shape2 and the intersection all covering the same bit of the map.
If I could 'cut-down' the two main shapes only the intersection shape would colour/cover that part of the map.
I do not think there are out of the box solutions in the Bing Maps API. I have done something similar in the past with Bing Maps API and SqlGeography Class though. Its easy to loop through the points of our Bing Polygons, therefore we can plot them into SqlGeography Polygons or SqlGeometry Polygons.
You will need the Microsoft.SqlServer.Types.dll to make use of this class, but it is free with SqlExpress.(Note that you do not actually need SQL Server installed, you just need to reference the DLL)
You can use the SqlGeography Class (or SqlGeometry Class) to find intersecting shapes and points. Perhaps have a look at STIntersection Method, According to MSDN STIntersection will;
"Returns an object representing the points where a SqlGeography instance intersects another SqlGeography instance."
Once you have the object representing the shape were a SqlGeography instance intersects another, you know you need to somehow adjust any points from the compaired instances that lie withing the SqlGeography instnace returned by StIntersection.
Here is a simular question where Peter uses STDifference. To subtract the two shapes.
I'll provide you with a c# example I made quickly for the Intersection. I had a lot of trouble finding any code examples for anything that wasn't purely SQL Server based.
SqlGeography Shape1 = new SqlGeography();
SqlGeographyBuilder geographyBuilder1 = new SqlGeographyBuilder();
geographyBuilder1.SetSrid(4326);
geographyBuilder1.BeginGeography(OpenGisGeographyType.Polygon);
geographyBuilder1.BeginFigure(47.4275329011347, -86.8136038458706);
geographyBuilder1.AddLine(36.5102408627967, -86.9680936860962);
geographyBuilder1.AddLine(37.4928909385966, -80.2884061860962);
geographyBuilder1.AddLine(38.7375329179818, -75.7180936860962);
geographyBuilder1.AddLine(48.0932596736361, -83.7161405610962);
geographyBuilder1.AddLine(47.4275329011347, -86.8136038458706);// Remember last point in the polygon should match the first
geographyBuilder1.EndFigure();
geographyBuilder1.EndGeography();
Shape1 = geographyBuilder1.ConstructedGeography;
SqlGeography Shape2 = new SqlGeography();
SqlGeographyBuilder geographyBuilder2 = new SqlGeographyBuilder();
geographyBuilder2.SetSrid(4326);
geographyBuilder2.BeginGeography(OpenGisGeographyType.Polygon);
geographyBuilder2.BeginFigure(47.4275329011347, -86.8136038458706);
geographyBuilder2.AddLine(36.5102408627967, -86.9680936860962);
geographyBuilder2.AddLine(37.4928909385966, -80.2884061860962);
geographyBuilder2.AddLine(47.4275329011347, -86.8136038458706);
geographyBuilder2.EndFigure();
geographyBuilder2.EndGeography();
Shape2 = geographyBuilder2.ConstructedGeography;
SqlGeography IntersectedShape = Shape1.STIntersection(Shape2);
I believe you can draw shapes with the new GeoRSS feature - it supports line, boxes, polygons and circles. GeoRSS was designed as a lightweight, community driven way to extend existing feeds with geographic information. Also check out GeoJson
I'm trying to figure out the best way to design Car and Road objects for a game design I'm working on.
The idea is for AI Cars (as well as the Player controlled car) to recognize when they traverse dotted lines or straight lines on the Roads.
I'd like to be able to build a Variable Lane Road for Unity3D with the appropriate flags and sub objects so that the Cars recognize where they are and when and how they traverse or take turns etc' etc'
For example, a Road can have a single direction or be in both directions.
For each direction there can be a number of lanes. Lanes allow cars to overtake each other (meaning a dotted line between the lanes).
If it's a bi directional road, then there's a line between the two lanes - optionally and ideally, if there's more than one lane on any of the directions, then the line that separates the directional lanes is straight.
By default, there should be a flag that draws the line according to an isOvertakingAllowed boolean flag.
The most important part is that the Car objects need to know what lane they are on or if they are on a lane separating line, and what type this separation is (overtaking allowed or not).
That's the hard part, to me.
Any help is appreciated.
I would recommend you implement a Lane, which have a direction of travel. Then implement a Road which has a collection of points, a path defining it's shape, and distance, and a collection of Lane objects that follow that path. Whether the road is one-way or two-way becomes a matter of which, and how many lanes they have.
In this case, a Car travels on a Road in a given direction, following the lane that it's in. It can only switch to other lanes that have compatible directions of travel (i.e. that are heading in the same direction as the car), unless the car turns around.
You might also have a special point in a Road called an Intersection which is a connection point for multiple Lanes, and somehow specify which Lanes a Car can transition to and from when it's at the Intersection.
That's a rough outline, but I think those are the basic relationships between the objects that you present, and should get you started.
There is an article on gamasutra with description of the model that was used for opencity, and how the different agents (standard car, racing car, pedestrian...) could use it. It may gives you some pointers or ideas.