geosolutions-it / MapStore2

The solution to create and share maps, dashboards, geostories with 3D support on the web. And it is open-source too!
https://mapstore.geosolutionsgroup.com/
Other
513 stars 401 forks source link

Add possibility to export annotations as multiple GeoJSON object #5540

Open MV88 opened 4 years ago

MV88 commented 4 years ago

Description

Some users asked how is possible to convert exported annotations to shapefile. This is not possible because the current format is a proprietary one

In this case we are exporting an object where in the "features" property is contained an array of feature collections {"features":[ ...FEATURE_COLLECTIONS ], "type": "ms2-annotations"}

Acceptance criteria

Other useful information

estudiocad commented 4 years ago

Hello, the annotation tool I am implementing so that users draw on the map, but later I cannot do searches on these, so I must load them in geoserver, also the json generated if it has a lot of information gets very slow. As a digitizing tool it is very good but perhaps you would have to save geometries in postgres on the fly. Thanks for the help

mbarto commented 4 years ago

@estudiocad please notice that if you want to edit spatial data on a database, you can also use the FeatureEditor with WFS layers.

Annotations are mostly for drawing something quick and simple that need to be saved together with the map, so they are not meant to be used with a lot of data.

The editing tools for the feature editor are similar, but results are saved on a spatial database using WFS-T

wdcsimon commented 3 years ago

Current annotation export to json won't open in QGIS directly, would be great if we could have the option to choose a standard GeoJSON format (usable directly in QGIS using the OGR GeoJSON driver).
So acceptance criteria would be...

A quick note on the existing json format too - the json export for polygons (and circles) needs to have start and end coordinates the same to be used as compliant geojson

Hope all that makes sense

allyoucanmap commented 1 year ago

I was playing around with some local node scripts to have a quick conversion from MapStore annotation to GeoJSON, I'm not sure it will cover all the cases but maybe could be useful for this thread to have a temporary tool to test while this feature is not implemented yet. Here steps I followed:

const msAnnotations = require(msAnnotationsPath);

msAnnotations.features.forEach(({ style, properties, ...collection }, idx) => { const geoJSON = { ...collection, features: collection.features.map(({ style: featureStyle, ...feature }) => { return { ...feature, properties: { ...properties, ...feature.properties } }; }) }; fs.writeFileSync(./${properties.title}-${idx}.json, JSON.stringify(geoJSON), ) });

- exported annotations from MapStore called `annotations.json` and placed the file inside the same folder of `msAnnotationsToGeoJSON.js`

ms-script/ ├─ annotations.json ├─ msAnnotationsToGeoJSON.js

- run the script to generate GeoJSON from MapStore Annotations
```shell
node ./msAnnotationsToGeoJSON.js "./annotations.json"

This script will generate a GeoJSON for each annotation. Note: you will need node installed to run the script

MapStore

image

QGIS

image