Node-Red Worldmap: Drawing polygon in worldmap

Hi,

Currently I am working on developing geofences for a project. I am using the Dashboard-Worldmap node in order to draw polygons and save them in a .json file. As it turns out though when executing a GeoIntersect query (mongoDB) with a coordinate point laying within the polygon I get an empty result. Further analysis shows me that the polygon created with the Dashboard-Worldmap node is without the start coordinate at the end, which results in a failing geointersect query.

Example of a rectangle drawing using the dashboard-worldmap node:

{
	"type": "FeatureCollection",
	"features": [
		{
			"type": "Feature",
			"properties": {
				"Port": "test"
			},
			"geometry": {
				"type": "Polygon",
				"coordinates": [
					[
						[
							5.075828271373202,
							52.5520956610614
						],
						[
							5.075828271373202,
							52.73619031754503
						],
						[
							5.562168359767676,
							52.73619031754503
						],
						[
							5.562168359767676,
							52.5520956610614
						]
					]
				]
			}
		}
	]
}

Example of a rectangle drawing for example in geojson.io:

{
	"type": "FeatureCollection",
	"features": [
		{
			"type": "Feature",
			"properties": {
				"Port": "Test"
			},
			"geometry": {
				"type": "Polygon",
				"coordinates": [
					[
						[
							5.211982727050781,
							52.605132598485969
						],
						[
							5.4087066650390629,
							52.605132598485969
						],
						[
							5.4087066650390629,
							52.72652036177586
						],
						[
							5.211982727050781,
							52.72652036177586
						],
						[
							5.211982727050781,
							52.605132598485969
						]
					]
				]
			}
		}
	]
}

Where the geojson.io adds the start point also as an end point, the worldmap-dashboard node does not. Is this normal functionality or is this a possible fix opportunity?

Node-red-dashboard version 3.1.7
Node-red-contrib-web-worldmap version 2.21.9

So how are you turning the returned shape into the geoJson ? - The worldmap uses Leaflet Draw - which only returns the 4 points (for a rectangle) - and also an option.fill set to true if it is supposed to be a filled (closed) object. - you could use this to trigger repeating the first coordinate and adding to the end for your conversion.

Hi dceejay,

Thanks for your swift reply! So I am using the worldmap interface to draw. I return the shape with the "worldmap in" node.

The output looks as follows, though already mentioning fill:true:

I am going to test your proposal with option.fill in the worldmap node and will report accordingly.

Fixed the issue. As you mentioned, standard functionality is not to have a closed object. Therefor the solution in the end is to get the first coordinate and add it to the end of the array. Now everything works just fine!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.