Skip to content

Commit

Permalink
Merge pull request #8646 from jef-n/gid7-fffix
Browse files Browse the repository at this point in the history
NAS driver update
  • Loading branch information
rouault authored Nov 2, 2023
2 parents a37925f + 903eaf3 commit a963578
Show file tree
Hide file tree
Showing 13 changed files with 447 additions and 911 deletions.
10 changes: 5 additions & 5 deletions autotest/ogr/ogr_nas.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_ogr_nas_1():
ds = ogr.Open("tmp/cache/BKG_NAS_Peine.xml")
assert ds is not None, "could not open dataset"

assert ds.GetLayerCount() == 41, "did not get expected layer count"
assert ds.GetLayerCount() == 40, "did not get expected layer count"

lyr = ds.GetLayerByName("AX_Wohnplatz")
feat = lyr.GetNextFeature()
Expand Down Expand Up @@ -140,7 +140,7 @@ def test_ogr_nas_2():
with gdal.config_option("NAS_GFS_TEMPLATE", ""):
ds = ogr.Open("tmp/cache/gm2566-testdaten-gid60-2008-11-11.xml")

assert ds.GetLayerCount() == 85, "did not get expected layer count"
assert ds.GetLayerCount() == 84, "did not get expected layer count"

lyr = ds.GetLayerByName("AX_Flurstueck")

Expand Down Expand Up @@ -170,7 +170,7 @@ def test_ogr_nas_3():
with gdal.config_option("NAS_GFS_TEMPLATE", ""):
ds = ogr.Open("data/nas/empty_nas.xml")

assert ds.GetLayerCount() == 1, "did not get expected layer count"
assert ds.GetLayerCount() == 0, "did not get expected layer count"

ds = None

Expand All @@ -190,7 +190,7 @@ def test_ogr_nas_4():
with gdal.config_option("NAS_GFS_TEMPLATE", ""):
ds = ogr.Open("data/nas/delete_nas.xml")

assert ds.GetLayerCount() == 2, "did not get expected layer count"
assert ds.GetLayerCount() == 1, "did not get expected layer count"

del_lyr = ds.GetLayerByName("Delete")

Expand Down Expand Up @@ -233,7 +233,7 @@ def test_ogr_nas_5():
with gdal.config_option("NAS_GFS_TEMPLATE", ""):
ds = ogr.Open("data/nas/replace_nas.xml")

assert ds.GetLayerCount() == 3, "did not get expected layer count"
assert ds.GetLayerCount() == 2, "did not get expected layer count"

# Check the delete operation created for the replace

Expand Down
30 changes: 15 additions & 15 deletions doc/source/drivers/vector/nas.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@ ax_flurstueck.objektkoordinaten next to the regular wkb_geometry).
Starting with GDAL 3.7, defining the NAS_GFS_TEMPLATE configuration option is
required for the NAS driver to open a file. It may be set to the empty string
to mean that the driver should try to establish the schema of the file from its
content, but using the below mentioned template is recommended.

A `GFS
template <https://github.com/norBIT/alkisimport/blob/master/alkis-schema.gfs>`__
and a corresponding `PostgreSQL
schema <https://github.com/norBIT/alkisimport/blob/master/alkis-schema.sql>`__
of the full NAS schema are part of `norGIS
ALKIS-Import <http://www.norbit.de/68/>`__ (also featuring a shell
script and PyQt frontend which ease the import). The two files were
generated using `xmi2db <https://github.com/norBIT/xmi2db/>`__ (fork of
content, but using one of templates mentioned below is recommended.

The GFS templates and PostgreSQL schemas are part of `norGIS
ALKIS-Import <http://www.norbit.de/68/>`__ (also featuring a shell script and
PyQt frontend which ease the import). There are currently two versions:

* GeoInfoDok 6: `GFS template <https://github.com/norBIT/alkisimport/blob/master/alkis-schema.gfs>`__ (for GDAL >=3.8 and `<3.8 <https://github.com/norBIT/alkisimport/blob/master/alkis-schema.37.gfs>`__) and `PostgreSQL schema <https://github.com/norBIT/alkisimport/blob/master/alkis-schema.sql>`__
* GeoInfoDok 7.1.2: `GFS template <https://github.com/norBIT/alkisimport/blob/gid7/alkis-schema.gfs>`__ and `PostgreSQL schema <https://github.com/norBIT/alkisimport/blob/gid7/alkis-schema.sql>`__

The files were generated using `xmi2db <https://github.com/norBIT/xmi2db/>`__ (fork of
`xmi2db <https://github.com/pkorduan/xmi2db>`__) from the official
application schema.

The configuration option **NAS_NO_RELATION_LAYER** allows
disabling populating the table *alkis_beziehungen*. The information found
there is redundant to the relation fields also contained in original
elements/tables. Enabling the option also makes progress reporting
available.
In GDAL 3.8 the creation of the relation layer *alkis_beziehungen* was removed. Prior
the configuration option **NAS_NO_RELATION_LAYER** allowed to disable its
population - which was default in ALKIS-Import. The information found there was
redundant to the relation fields also contained in original elements/tables.
Enabling the option also made progress reporting available.

This driver was implemented within the context of the `PostNAS
project <http://trac.wheregroup.com/PostNAS>`__, which has more
Expand Down
1 change: 1 addition & 0 deletions ogr/ogr_xerces_headers.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

#include <xercesc/framework/MemoryManager.hpp>
#include <xercesc/sax/InputSource.hpp>
#include <xercesc/sax/Locator.hpp>
#include <xercesc/util/BinInputStream.hpp>
#include <xercesc/util/OutOfMemoryException.hpp>
#include <xercesc/util/PlatformUtils.hpp>
Expand Down
34 changes: 1 addition & 33 deletions ogr/ogrsf_frmts/gml/gmlfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
GMLFeature::GMLFeature(GMLFeatureClass *poClass)
: m_poClass(poClass), m_pszFID(nullptr), m_nPropertyCount(0),
m_pasProperties(nullptr), m_nGeometryCount(0),
m_papsGeometry(m_apsGeometry), // TODO(schwehr): Allowed in init list?
m_papszOBProperties(nullptr)
m_papsGeometry(m_apsGeometry) // TODO(schwehr): Allowed in init list?
{
m_apsGeometry[0] = nullptr;
m_apsGeometry[1] = nullptr;
Expand Down Expand Up @@ -90,7 +89,6 @@ GMLFeature::~GMLFeature()
CPLDestroyXMLNode(m_psBoundedByGeometry);

CPLFree(m_pasProperties);
CSLDestroy(m_papszOBProperties);
}

/************************************************************************/
Expand Down Expand Up @@ -299,33 +297,3 @@ void GMLFeature::SetBoundedByGeometry(CPLXMLNode *psGeom)
CPLDestroyXMLNode(m_psBoundedByGeometry);
m_psBoundedByGeometry = psGeom;
}

/************************************************************************/
/* AddOBProperty() */
/************************************************************************/

void GMLFeature::AddOBProperty(const char *pszName, const char *pszValue)

{
m_papszOBProperties =
CSLAddNameValue(m_papszOBProperties, pszName, pszValue);
}

/************************************************************************/
/* GetOBProperty() */
/************************************************************************/

const char *GMLFeature::GetOBProperty(const char *pszName)

{
return CSLFetchNameValue(m_papszOBProperties, pszName);
}

/************************************************************************/
/* GetOBProperties() */
/************************************************************************/

char **GMLFeature::GetOBProperties()
{
return m_papszOBProperties;
}
8 changes: 0 additions & 8 deletions ogr/ogrsf_frmts/gml/gmlreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,6 @@ class CPL_DLL GMLFeature
m_nGeometryCount <= 1 */
CPLXMLNode *m_apsGeometry[2]; /* NULL-terminated */

// string list of named non-schema properties - used by NAS driver.
char **m_papszOBProperties;

CPLXMLNode *m_psBoundedByGeometry = nullptr;

public:
Expand Down Expand Up @@ -427,11 +424,6 @@ class CPL_DLL GMLFeature
void SetFID(const char *pszFID);

void Dump(FILE *fp);

// Out of Band property handling - special stuff like relations for NAS.
void AddOBProperty(const char *pszName, const char *pszValue);
const char *GetOBProperty(const char *pszName);
char **GetOBProperties();
};

/************************************************************************/
Expand Down
1 change: 0 additions & 1 deletion ogr/ogrsf_frmts/nas/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ add_gdal_driver(
ogrnasdatasource.cpp
ogrnasdriver.cpp
ogrnaslayer.cpp
ogrnasrelationlayer.cpp
BUILTIN) # BUILTIN because of GML dependency
gdal_standard_includes(ogr_NAS)
target_include_directories(ogr_NAS PRIVATE $<TARGET_PROPERTY:ogr_GML,SOURCE_DIR>)
Expand Down
Loading

0 comments on commit a963578

Please sign in to comment.