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

Reading the geometry type: type ID always 0? #38

Closed
Vectorial1024 opened this issue Jul 24, 2023 · 2 comments
Closed

Reading the geometry type: type ID always 0? #38

Vectorial1024 opened this issue Jul 24, 2023 · 2 comments

Comments

@Vectorial1024
Copy link

Recently, I have been trying to convert a GeoJSON file to an OSM file using ogr2osm, and also learn more about ogr2osm.

I am following the hints in #36 to extract the elevation of points, but I noticed an inconsistency, as shown below:

class TestTranslation(ogr2osm.TranslationBase):
    def filter_feature(self, ogrfeature, layer_fields, reproject):
        geom_name = ogrfeature.GetGeometryRef().GetGeometryName()
        # can show e.g. LINESTRING

        geom_type = ogrfeature.GetGeometryRef().GetGeometryType()
        # always 0, which seemingly does not correspond to any of the OGRwkbGeometryType values

Is it normal to have geometry type to be always 0 when I am reading from a GeoJSON?

@roelderickx
Copy link
Owner

roelderickx commented Jul 25, 2023

Type 0 corresponds to the constant wkbUnknown. Assuming you are starting from a geojson file, what type is your feature?

I tried with

    [ ... ]
      "geometry": {
        "type": "LineString",
        "coordinates": [ ... ]

and a slightly modified translation file

class TestTranslation(ogr2osm.TranslationBase):
    def filter_feature(self, ogrfeature, layer_fields, reproject):
        geom_name = ogrfeature.GetGeometryRef().GetGeometryName()
        print("name: %s" % geom_name)
        # can show e.g. LINESTRING

        geom_type = ogrfeature.GetGeometryRef().GetGeometryType() + 2**32 # convert to unsigned
        # always 0, which seemingly does not correspond to any of the OGRwkbGeometryType values
        print("type: %d" % geom_type)

Resulting in

name: LINESTRING
type: 2147483650

where 2147483650 corresponds to wkbLineString25D (I added the third dimension to all coordinates to investigate another issue)

@roelderickx
Copy link
Owner

Did you find out where the 0 came from? Was it due to the necessary conversion to an unsigned int or a wrong format while printing? Something with the input file which wasn't correct?

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

No branches or pull requests

2 participants