Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass svg attribute data to geojson features. #6

Open
wizzfizz94 opened this issue Mar 14, 2018 · 6 comments
Open

Pass svg attribute data to geojson features. #6

wizzfizz94 opened this issue Mar 14, 2018 · 6 comments

Comments

@wizzfizz94
Copy link

Need a way pass attribute data across. possibly to feature properties.

@Phrogz
Copy link
Owner

Phrogz commented May 24, 2018

Can you elaborate on this request? What attribute data do you want passed, to where/what function, for what purpose?

@Phrogz
Copy link
Owner

Phrogz commented Sep 20, 2019

@wizzfizz94 Ping.

@Crisfole
Copy link

Crisfole commented Sep 20, 2019

I'm not wizzfizz, but we're have something like this:

<g id="WATER">
  <path id="POOL" d="M11333.8,11015C11356.3,11167 11234.8,11334.9 11330.6,11448.9C11426.5,11562.9 11705,11651.8 11801.8,11507C11898.6,11362.2 11974.9,11173.8 11974.9,10979.8C11974.9,10785.8 11940.3,10569.1 11859.3,10440.8C11778.2,10312.6 11603.4,10207.8 11429.7,10302.1C11256,10396.4 11162.1,10541.9 11203.3,10693.8C11244.5,10845.8 11312.1,10868.5 11333.8,11015Z" style="fill:rgb(189,222,229);"/>
</g>

And we'd like the ID passed through to the feature. Not terribly fussy about how its formatted, just so we can find it programatically:

{
  "type": "Feature",
  "properties": {
    "id": "POOL",
    "class": "WATER WATERSPARENT"
  },
  "geometry": {
    "type": "Polygon",
    "coordinates": [
      [
        [
          -122.24306374398041,
          47.922757305314946
        ],
        [
          -122.2430642555439,
          47.922748481530625
        ],
        [
          -122.2430681239193,
          47.92273548453174
        ],
        [
          -122.2430671292968,
          47.922727705575326
        ],
        [
          -122.2430641094084,
          47.922724268647684
        ],
        [
          -122.24305263607624,
          47.922718365265915
        ],
        [
          -122.24302929594788,
          47.92271411109429
        ],
        [
          -122.2430153368401,
          47.92271651369286
        ],
        [
          -122.24301030013899,
          47.922719844977784
        ],
        [
          -122.24300254799846,
          47.922728690889976
        ],
        [
          -122.24299206692459,
          47.92274903234796
        ],
        [
          -122.24299053276944,
          47.92275998540411
        ],
        [
          -122.2429912946725,
          47.92277125550739
        ],
        [
          -122.24299776888572,
          47.922792567974234
        ],
        [
          -122.24300373385506,
          47.92280102426942
        ],
        [
          -122.24301251697355,
          47.922807801939854
        ],
        [
          -122.24303099508538,
          47.922813972268756
        ],
        [
          -122.24304536935894,
          47.9228135927342
        ],
        [
          -122.24305279256077,
          47.92281158473438
        ],
        [
          -122.24306586214229,
          47.922805522174734
        ],
        [
          -122.2430777639557,
          47.9227943868611
        ],
        [
          -122.24307970007268,
          47.922786068686634
        ],
        [
          -122.24307864659005,
          47.922781761128554
        ],
        [
          -122.2430703602252,
          47.92276937618528
        ],
        [
          -122.24306374398041,
          47.922757305314946
        ],
        [
          -122.24306374398041,
          47.922757305314946
        ]
      ]
    ]
  }
}

@wizzfizz94
Copy link
Author

Yes the feature that @Crisfole would like is what i meant. The ability to for all arbitrary svg attributes to be included in the geojosn parse. I think i ended up hacking the module but for a hacky hard coded fix so i wont upload it.

@DavidCampbellTech
Copy link

We too have the same need. We'd like to pass id's on svg elements (not just the group) all the way through to the postgis database, svg -> geojson -> shape file - db.

Its quite important in order to make interactive maps.

@SimonasPetk
Copy link

SimonasPetk commented Jun 21, 2022

I solved this issue by running in debug mode. As debug mode adds svgID into the properties field. (see lib/svg2geojson.js, line 68 for part of code responsible for it.)

svg2geojson ../clean-1-part.svg --debug

returns

{"type":"Feature","properties":{"svgID":"1"},"geometry":{"type":"LineString","coordinates":[...........]}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants