Skip to content

Instantly share code, notes, and snippets.

@springmeyer
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save springmeyer/10410307 to your computer and use it in GitHub Desktop.
Save springmeyer/10410307 to your computer and use it in GitHub Desktop.
OpenFileGDB rendering with SetSpatialFilterRect

Bug description

When reading from the cdfadmin13_1_unit layer of cdfadmin13_1.gdb with OpenFileGDB driver and setting a SetSpatialFilterRect from Mapnik I'm seeing not all shapes returned. The incorrect.png demostrates this. It should be a solid red color, but instead some polygons are missing and the shapefile underneath renders green and shows through.

Data from: http://frap.cdf.ca.gov/data/statewide/cdfadmin13_1.zip downloaded from http://frap.cdf.ca.gov/data/frapgisdata-sw-cdfadmin13_1_download.php

I found:

  • disabling SetSpatialFilterRect works around the problem (produces no_filter.png below)
  • disabling GEOS support in GDAL also works around the problem (produces no_geos.png below)
  • converting to a shapefile with ogr2ogr cdfadmin13_1_unit.shp cdfadmin13_1.gdb cdfadmin13_1_unit and then reading that also works around the problem
  • Converting to sqlite ogr2ogr -f SQlite cdfadmin13_1_unit.db cdfadmin13_1.gdb cdfadmin13_1_unit DOES NOT WORK AROUND the problem (is missing same shapes as OpenFileGDB)

Details:

DOES NOT REPLICATE on Ubuntu Precise 64 bit with the same setup I used on OS X:

sudo apt-get update -y
sudo apt-get install -y git libtool g++ build-essential autotools-dev automake cmake make python-dev unzip python-nose python-pip
git clone https://github.com/mapnik/mapnik-packaging.git
cd mapnik-packaging/osx
source Linux.sh
./scripts/build_pkg_config.sh
./scripts/build_bzip2.sh
./scripts/build_icu.sh
BOOST_LIBRARIES="--with-thread --with-filesystem --disable-filesystem2 --with-system --with-regex --with-program_options"
./scripts/build_boost.sh ${BOOST_LIBRARIES}
./scripts/build_freetype.sh
./scripts/build_harfbuzz.sh
./scripts/build_libxml2.sh
./scripts/build_jpeg_turbo.sh
./scripts/build_png.sh
./scripts/build_proj4.sh
./scripts/build_webp.sh
./scripts/build_tiff.sh
./scripts/build_sqlite.sh
./scripts/build_expat.sh
./scripts/build_geos.sh
./scripts/build_gdal.sh
./scripts/build_postgres.sh
./scripts/build_python_versions.sh
mapnik_branch="2.3.x"
git clone --quiet https://github.com/mapnik/mapnik.git ${MAPNIK_SOURCE} -b $mapnik_branch
./scripts/build_mapnik.sh
./scripts/post_build_fix.sh
./scripts/test_mapnik.sh

# setup
export PYTHONPATH=${MAPNIK_BIN_SOURCE}/lib/python2.7/site-packages/
export LD_LIBRARY_PATH=${MAPNIK_BIN_SOURCE}/lib/
export ICU_DATA="${MAPNIK_BIN_SOURCE}/share/mapnik/icu"
export GDAL_DATA="${MAPNIK_BIN_SOURCE}/share/mapnik/gdal"
export PROJ_LIB="${MAPNIK_BIN_SOURCE}/share/mapnik/proj"
export MAPNIK_FONT_DIRECTORY=${MAPNIK_BIN_SOURCE}/lib/mapnik/fonts/
export MAPNIK_INPUT_PLUGINS_DIRECTORY=${MAPNIK_BIN_SOURCE}/lib/mapnik/input/
sudo pip install nik2img
$ nik2img.py map.xml -e -13711788.5421 4158429.39087 -12723990.1544 4816961.64939 incorrect.png
Shape: DBF Codepage = LDID/87 for cdfadmin13_1_unit.shp
Shape: Treating as encoding 'ISO-8859-1'.
OGR: OGROpen(cdfadmin13_1_unit.shp/0x7fa56487d3a0) succeeded as ESRI Shapefile.
OpenFileGDB: FileGDB v10 or later
OGR: OGROpen(cdfadmin13_1.gdb/0x7fa56487fe90) succeeded as OpenFileGDB.
CPLQuadTree: Estimated spatial index tree depth: 3
Mapnik LOG> 2014-04-10 14:46:48: ogr_featureset: 14 features
OpenFileGDB: Unhandled geometry type = 536870963
OpenFileGDB: Unhandled geometry type = 536870963
OpenFileGDB: Unhandled geometry type = 536870963
OpenFileGDB: Unhandled geometry type = 536870963
OpenFileGDB: Unhandled geometry type = 536870963
OpenFileGDB: SPI_COMPLETED
Mapnik LOG> 2014-04-10 14:46:48: ogr_featureset: 12 features
Shape: 19 features read on layer 'cdfadmin13_1_unit'.
$ nik2img.py map.xml -e -13711788.5421 4158429.39087 -12723990.1544 4816961.64939 no_filter.png
Shape: DBF Codepage = LDID/87 for cdfadmin13_1_unit.shp
Shape: Treating as encoding 'ISO-8859-1'.
OGR: OGROpen(cdfadmin13_1_unit.shp/0x7fa5f2fa0af0) succeeded as ESRI Shapefile.
OpenFileGDB: FileGDB v10 or later
OGR: OGROpen(cdfadmin13_1.gdb/0x7fa5f2fa35e0) succeeded as OpenFileGDB.
CPLQuadTree: Estimated spatial index tree depth: 3
Mapnik LOG> 2014-04-10 14:47:26: ogr_featureset: 22 features
OpenFileGDB: Unhandled geometry type = 536870963
OpenFileGDB: Unhandled geometry type = 536870963
OpenFileGDB: Unhandled geometry type = 536870963
OpenFileGDB: Unhandled geometry type = 536870963
OpenFileGDB: Unhandled geometry type = 536870963
OpenFileGDB: SPI_COMPLETED
Mapnik LOG> 2014-04-10 14:47:26: ogr_featureset: 22 features
Shape: 27 features read on layer 'cdfadmin13_1_unit'.
$ nik2img.py map.xml -e -13711788.5421 4158429.39087 -12723990.1544 4816961.64939 no_filter.png
Shape: DBF Codepage = LDID/87 for cdfadmin13_1_unit.shp
Shape: Treating as encoding 'ISO-8859-1'.
OGR: OGROpen(cdfadmin13_1_unit.shp/0x7f81b074f4b0) succeeded as ESRI Shapefile.
OpenFileGDB: FileGDB v10 or later
OGR: OGROpen(cdfadmin13_1.gdb/0x7f81b0751fa0) succeeded as OpenFileGDB.
CPLQuadTree: Estimated spatial index tree depth: 3
Mapnik LOG> 2014-04-10 14:51:06: ogr_featureset: 22 features
OpenFileGDB: Unhandled geometry type = 536870963
OpenFileGDB: Unhandled geometry type = 536870963
OpenFileGDB: Unhandled geometry type = 536870963
OpenFileGDB: Unhandled geometry type = 536870963
OpenFileGDB: Unhandled geometry type = 536870963
OpenFileGDB: SPI_COMPLETED
Mapnik LOG> 2014-04-10 14:51:06: ogr_featureset: 22 features
Shape: 27 features read on layer 'cdfadmin13_1_unit'.

This does not work around the problem:

diff --git a/gdal/ogr/ogrsf_frmts/generic/ogrlayer.cpp b/gdal/ogr/ogrsf_frmts/generic/ogrlayer.cpp
index 8a15c61..c884dc3 100644
--- a/gdal/ogr/ogrsf_frmts/generic/ogrlayer.cpp
+++ b/gdal/ogr/ogrsf_frmts/generic/ogrlayer.cpp
@@ -1269,7 +1269,7 @@ int OGRLayer::FilterGeometry( OGRGeometry *poGeometry )
         if( OGRGeometryFactory::haveGEOS() )
         {
             //CPLDebug("OGRLayer", "GEOS intersection");
-            if( m_pPreparedFilterGeom != NULL )
+            if( 0 && m_pPreparedFilterGeom != NULL )
                 return OGRPreparedGeometryIntersects(m_pPreparedFilterGeom,
                                                      poGeometry);
             else
This file has been truncated, but you can view the full file.
View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

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