forked from MapComplete/MapComplete
		
	More svelte work
This commit is contained in:
		
							parent
							
								
									890980d534
								
							
						
					
					
						commit
						112162e6c8
					
				
					 6 changed files with 75 additions and 31 deletions
				
			
		|  | @ -209,11 +209,15 @@ export class GeoOperations { | |||
|      * GeoOperations.inside([1.42822265625, 48.61838518688487], multiPolygon) // => false
 | ||||
|      * GeoOperations.inside([4.02099609375, 47.81315451752768], multiPolygon) // => false
 | ||||
|      */ | ||||
|     public static inside(pointCoordinate: [number, number] | Feature<Point>, feature): boolean { | ||||
|     public static inside( | ||||
|         pointCoordinate: [number, number] | Feature<Point>, | ||||
|         feature: Feature | ||||
|     ): boolean { | ||||
|         // ray-casting algorithm based on
 | ||||
|         // http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
 | ||||
| 
 | ||||
|         if (feature.geometry.type === "Point") { | ||||
|             // The feature that should 'contain' pointCoordinate is a point itself, so it cannot contain anything
 | ||||
|             return false | ||||
|         } | ||||
| 
 | ||||
|  | @ -227,6 +231,7 @@ export class GeoOperations { | |||
|         if (feature.geometry.type === "MultiPolygon") { | ||||
|             const coordinatess = feature.geometry.coordinates | ||||
|             for (const coordinates of coordinatess) { | ||||
|                 // @ts-ignore
 | ||||
|                 const inThisPolygon = GeoOperations.pointInPolygonCoordinates(x, y, coordinates) | ||||
|                 if (inThisPolygon) { | ||||
|                     return true | ||||
|  | @ -236,6 +241,7 @@ export class GeoOperations { | |||
|         } | ||||
| 
 | ||||
|         if (feature.geometry.type === "Polygon") { | ||||
|             // @ts-ignore
 | ||||
|             return GeoOperations.pointInPolygonCoordinates(x, y, feature.geometry.coordinates) | ||||
|         } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue