roelderickx / ogr2osm

A tool for converting ogr-readable files like shapefiles into .pbf or .osm data
https://pypi.org/project/ogr2osm/
MIT License
59 stars 14 forks source link

Coordinate accuracy #4

Open roelderickx opened 3 years ago

roelderickx commented 3 years ago

After a system upgrade (python from version 3.9.2 to 3.9.4 and GDAL from version 3.0.4 to 3.2.2) the testcases fail. Here is an example of the first nodes before and after the upgrade:

-  <node visible="true" id="-2" lat="49.210517895" lon="-122.869117973"/>
+  <node visible="true" id="-2" lat="49.210518573" lon="-122.869133894"/>

-  <node visible="true" id="-3" lat="49.210522516" lon="-122.867400328"/>
+  <node visible="true" id="-3" lat="49.210523197" lon="-122.8674163"/>

-  <node visible="true" id="-5" lat="49.211948022" lon="-122.86739095"/>
+  <node visible="true" id="-5" lat="49.211948704" lon="-122.867406972"/>

-  <node visible="true" id="-6" lat="49.211944294" lon="-122.864626998"/>
+  <node visible="true" id="-6" lat="49.211944981" lon="-122.864643102"/>

-  <node visible="true" id="-8" lat="49.208017674" lon="-122.87588432"/>
+  <node visible="true" id="-8" lat="49.208018337" lon="-122.875899951"/>

A similar problem can be seen for the tags. However, contrary to the coordinates which are fetched as doubles the attributes are fetched as string.

-    <tag k="YTD_COST" v="1.54"/>
+    <tag k="YTD_COST" v="1.540000000000000"/>

-    <tag k="LC_COST" v="19.60"/>
+    <tag k="LC_COST" v="19.600000000000001"/>

This leaves a couple of open questions:

roelderickx commented 3 years ago

I have tried downgrading GDAL to version 3.0.4 to no effect. I set up docker using the Dockerfile from @HSLdevcom (thanks!) but the results are still not the same as before.

roelderickx commented 3 years ago

An updated docker image is available in the master branch using the default ubuntu packages for GDAL. All test cases pass succesfully in this image, at least there is a reliable test environment now. The problem described in this issue is reproducible using the docker image from osgeo/gdal, using the latest version of GDAL.

FROM osgeo/gdal:ubuntu-full-3.2.2

WORKDIR /app

RUN apt-get update \
  && apt-get install -y \
    libprotobuf-dev \
    libxml2-utils \
    osmctools \
    protobuf-compiler \
    python3-pip

RUN pip3 install \
  --no-cache-dir \
  cram \
  lxml \
  protobuf

# A clumsy hack to avoid errors
RUN cd /usr/lib/python3/dist-packages/osgeo \
  && ln -s ./_gdal.cpython*.so ./_gdal.so \
  && ln -s ./_gdal_array.cpython*.so ./_gdal_array.so \
  && ln -s ./_gdalconst.cpython*.so ./_gdalconst.so \
  && ln -s ./_gnm.cpython*.so ./_gnm.so \
  && ln -s ./_ogr.cpython*.so ./_ogr.so \
  && ln -s ./_osr.cpython*.so ./_osr.so

ENV PYTHONPATH=/usr/lib/python3/dist-packages/