In Leaflet how to quarter a circle?

2081
2
Jump to solution
07-13-2016 09:19 AM
BillChappell
Occasional Contributor II

I need to use a circle to select points, but I need to identify which points are in the NE, SE, SW, NW quads of the circle.. Since my circle is created by Lat/Long and a Radius, with the Radius being in meters how can I draw a line to bisect it into quarters?

 

My thoughts were to first select the points by circle, then create 4 squares(quads) and use them to further select the points inside the circle. However it turns out you need lat/longs to draw a square and I'd need to figure out how to get the Min/Max values for a square so many meters wide. Finally for the map graphic I'd have to clip the box using the circle.

 

My second option was create 4 arrays (NE,SE, SW, NW) and just run a check to see if they are North and East of the circle center coordinate, etc and place them in the correct array, than symbolize then using different colors based on array values.

 

Does anyone have any thoughts, Ideas, links, or code examples?

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
JohnGravois
Frequent Contributor

your second option sounds reasonable to me.

just as a reminder, in Leaflet, when you call L.circle.toGeoJSON(), all that is returned is a point.  i wrote/cribbed some code to generate actual polygonal geometries and calculate area that you can check out here​, but i'd argue it might be overkill in this case.

View solution in original post

2 Replies
JohnGravois
Frequent Contributor

your second option sounds reasonable to me.

just as a reminder, in Leaflet, when you call L.circle.toGeoJSON(), all that is returned is a point.  i wrote/cribbed some code to generate actual polygonal geometries and calculate area that you can check out here​, but i'd argue it might be overkill in this case.

BillChappell
Occasional Contributor II

I solved the circle to GeoJSOn issue by first getting the points within the circles bounding box, then I loop through the data and check :

if (distance_from_centerPoint <= theRadius) {

    myData.push(layer.feature);

}

It's fairly quick to get all the address points and attributes within my mile or 1/2 mile circle.

Thanks It looks like option 2 with 4 different colors is it.

0 Kudos