S
S
Seva2018-11-26 17:18:48
JavaScript
Seva, 2018-11-26 17:18:48

How to convert SVG polygons and rectangles to geoJSON?

Hello,
There is a simple floor plan editor - it is an SVG for the height \ width of the container, where the user can draw \ delete \ copy polygons and rectangles with the mouse. The floor plan itself is a base64 encoded image pasted into an SVG. All this works on d3 and looks something like this:
5bfbffd607833538055938.png5bfc0016f394e587559696.png
The customer wants all this stuff to be stored in geoJSON format. Question - how, what to use? I tried to google, read the d3 documentation - basically the reverse options are described everywhere, how geoJSON is converted to SVG. Moreover, complex three-dimensional projections are usually used, which I clearly do not need for a flat plan.
Am I not looking there? Or geoJSON is not relevant at all in this case? Suggest something.
Thanks a lot.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Proskurin, 2018-11-26
@Vlad_IT

What are the problems? Get all the objects on the canvas with their coordinates and shape type, and convert them to the form
{

"type": "Polygon", 
    "coordinates": [
        
    ]
}

where coordinates describes the polygon vertex points.
Not so difficult. Read that one https://en.wikipedia.org/wiki/GeoJSON

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question