perliedman / ocad2geojson

JavaScript OCAD file reader and exporter for GeoJSON, SVG and Mapbox Style Spec
https://www.liedman.net/ocad2geojson/
GNU Affero General Public License v3.0
39 stars 4 forks source link

Possible duplicate Feature entry for point objects? #24

Closed aopheim closed 10 months ago

aopheim commented 10 months ago

I notice that point objects (knolls in this case) get two elements in the features list. Exporting a new OCAD map with a single knoll gives the following geojson file:

{
  type: 'FeatureCollection',
  features: [
    {
      type: 'Feature',
      properties: {
        sym: 109000,
        otp: 1,
        unicode: 0,
        ang: 0,
        col: 5,
        lineWidth: 0,
        diamFlags: 0,
        serverObjectId: -1,
        height: 0,
        creationDate: 45257.96000232639,
        multirepresentationId: 0,
        modificationDate: 45257.96048340278,
        nItem: 1,
        nText: 0,
        nObjectString: 0,
        nDatabaseString: 0,
        objectStringType: 0,
        res1: 0,
        text: '',
        objectString: '',
        databaseString: '',
      },
      id: 1,
      geometry: {
        type: 'Point',
        coordinates: [10.51176, 0.000384],
      },
    },
    {
      type: 'Feature',
      properties: {
        element: '109000-element-0',
        parentId: 1,
      },
      id: 2,
      geometry: {
        type: 'Point',
        coordinates: [10.51176, 0.000384],
      },
    },
  ],
};

Why is this represented as two features? It seems unnecessary to me, but I am not familiar that with the geojson format. Do we have to filter out all features having parentId property set in order to get the number of point features on the map?

perliedman commented 10 months ago

In OCAD, some symbols (style for a map feature) can include a number of elements, which in turn have special styling. For example, elements are how cliff "tags" are added: the cliff itself is a line, and it has a perpendicular element set at a certain interval which becomes the tags. Walls and a lot of other features also use them. If you're using the OCAD data to make a visual map with styling similar to a normal orienteering map, the elements are often desired in the GeoJSON since they are a bit tricky to position correctly.

Having said that, there is an option, generateSymbolElements, which you can set to false (it defaults to true), which will prevent these features from being created in the output.

aopheim commented 10 months ago

Ok, thanks! Nice to have the generateSymbolElements option available. I will probably not need it in my use case.