Using leaflet to determine if a line intersects through a polygon [duplicate] - leaflet

I am trying to work out the best way to determine if a line goes through a polygon, where it is possible that that points on that line do no fall within the polygon as shown in image below.
My data is multiple polygons and I wish to see if a line (lat,long to lat,long) goes through 1 or more of the polygons.
leaflet has a leaflet-pip that does a point in a polygon but I need to test a line... turf.js has lineIntersect but would this work with a line and a polygon (JSON)? Is there something else I can use but haven't found yet?
Just after some advice on the best way or library to achieve this
Thank you.

turf booleanIntersects works nicely.
Example here: https://codesandbox.io/s/ripkk?file=/src/index.js:9634-9641

Related

Using leaflet to determine if a line intersects through a polygon

I am trying to work out the best way to determine if a line goes through a polygon, where it is possible that that points on that line do no fall within the polygon as shown in image below.
My data is multiple polygons and I wish to see if a line (lat,long to lat,long) goes through 1 or more of the polygons.
leaflet has a leaflet-pip that does a point in a polygon but I need to test a line... turf.js has lineIntersect but would this work with a line and a polygon (JSON)? Is there something else I can use but haven't found yet?
Just after some advice on the best way or library to achieve this
Thank you.
turf booleanIntersects works nicely.
Example here: https://codesandbox.io/s/ripkk?file=/src/index.js:9634-9641

Leaflet: Polygonmarker instead of circlemarker

I am looking for a way to display a polygonmarker instead of a circlemarker in leaflet.
I am not looking for a way to draw a polygon on the map, because I need it to be the same size independent of zoomlevel.
Drawing a polygon also requires multiple coordinates which I don't have.
example: There is a spot on a mountain that allows to start flying here in winddirections from North to Southwest.
I want to draw a cone in those directions.
Can this be done in leaflet? I've looked around but can't find a solution to this.
If not, any suggestions?

Polyline changes the order of points

I would like leaflet to connect points in polyline in the same order as they were passed into constructor (L.polyline(route, routeOptions).addTo(map) where route is an array of points), but it seems to me that polyline does not care about order at all. Any suggestions would be highly appreciated.
What makes you think that Leaflet polyline does not care at all about the order in the array of points (coordinates)?
L.polyline(arrayOfLatLngs) should draw a segmented line passing by all the specified coordinates in arrayOfLatLngs, in the order they are set in the array.
Demo: http://jsfiddle.net/ve2huzxw/91/
If it does not behave that way for you, please provide your code and if possible reproduce your issue online (e.g. on jsfiddle) so that people can investigate.

QGIS polyline to polygon error

I have a set of polylines in qgis saved as .shp but when the geometry lines to polygons tool is used it fills in the areas on the outside of the lines, forming some strange polygon. Any thoughts?
A screenshot of your result might help here. That being said, you could try the Topology Checker plugin and check for dangles. If you find a bunch, your lines may not be closing properly, so the tool can't form polygons as intended.
Also, there is a GIS-themed Stack Exchange, which may answer your future questions better.

Geoserver - How do I draw a geodesic line that represents the great circle between two points

I'm using Geoserver version 2.1.1, Postgres 9 and PostGIS 2.0
What I want to achieve should (i think!) be quite straight forward. I want to render on a map a line that represents the Great Circle between two cities on the earths surface.
My database contains the city locations represented as geography points defined as latitude and lonfitude pairs.
I have a layer defining an SQL view in Geoserver which retrieves a linestring (st_makeline) from the two coordinates for the specified cities. I'm having to type cast the geographies to geometries to get this to work.
But when I draw the returned line on a map what i get is a straight line and not the curved line that I am expecting.
Can someone tell me how I should be going about this?
Thanks!
PostGIS offers mainly "constructors" of the base geometries point, linestring and polygone, like ST_MakeLine.
And what yo uwant to do depends also on the coordinate reference system you use when displaying your map layers.
Here's a nice trick about great circles or parts of:
https://gis.stackexchange.com/questions/5204/curved-point-to-point-route-maps
Yours, Stefan
P.S. Here's some related stuff:
Drawing circles on a sphere
And here's some math:
http://www.mathworks.ch/matlabcentral/newsreader/view_thread/277881
I had a similar problem in cartodb (which also uses PostGIS); I wanted to get curved lines from straight lines. Maybe this post can help.