Mapper  0.9.0
API documentation
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | List of all members
OpenOrienteering::OgrFileImport Class Reference

An Importer for geospatial vector data supported by OGR. More...

#include <ogr_file_format_p.h>

Inheritance diagram for OpenOrienteering::OgrFileImport:
Inheritance graph
[legend]
Collaboration diagram for OpenOrienteering::OgrFileImport:
Collaboration graph
[legend]

Public Types

enum  UnitType { UnitOnGround, UnitOnPaper }
 The unit type indicates the coordinate system the data units refers to. More...
 
using MapCoordConstructor = MapCoord(OgrFileImport::*)(double, double) const
 A Pointer to a function which creates a MapCoordF from double coordinates. More...
 

Public Member Functions

 OgrFileImport (const QString &path, Map *map, MapView *view, UnitType unit_type=UnitOnGround)
 Constructs a new importer. More...
 
 ~OgrFileImport () override
 
bool supportsQIODevice () const noexcept override
 Returns true when the importer/exporter supports QIODevice. More...
 
void setGeoreferencingImportEnabled (bool enabled)
 Enables the import of georeferencing from the geospatial data. More...
 
- Public Member Functions inherited from OpenOrienteering::Importer
 Importer (const QString &path, Map *map, MapView *view)
 Creates a new Importer with the given input path, map, and view. More...
 
 ~Importer () override
 Destroys this Importer. More...
 
bool loadSymbolsOnly () const noexcept
 Returns true if only symbols (and colors) are to be imported. More...
 
void setLoadSymbolsOnly (bool value)
 If set to true, importers shall import only symbols (and colors). More...
 
bool doImport ()
 Imports the map and view. More...
 
- Public Member Functions inherited from OpenOrienteering::ImportExport
 ImportExport (QIODevice *device=nullptr)
 Creates a new importer or exporter with the given IO device. More...
 
 ImportExport (const ImportExport &)=delete
 
 ImportExport (ImportExport &&)=delete
 
virtual ~ImportExport ()
 Destroys an importer or exporter. More...
 
QIODevicedevice () const noexcept
 Returns the input device if it has been set or created. More...
 
void setDevice (QIODevice *device)
 Sets a custom input device to be used for import. More...
 
void setOption (const QString &name, const QVariant &value)
 Sets an option in this importer or exporter. More...
 
QVariant option (const QString &name) const
 Retrieves the value of an option in this instance. More...
 
void addWarning (const QString &str)
 Adds a string to the current list of warnings. More...
 
const std::vector< QString > & warnings () const noexcept
 Returns the current list of warnings collected by this object. More...
 

Static Public Member Functions

static bool checkGeoreferencing (const QString &path, const Georeferencing &georef)
 Tests if the file's spatial references can be used with the given georeferencing. More...
 
static LatLon calcAverageLatLon (const QString &path)
 Calculates the average geographic coordinates (WGS84) of the file. More...
 

Protected Types

using ObjectList = std::vector< Object * >
 

Protected Member Functions

ogr::unique_srs srsFromMap ()
 
bool importImplementation () override
 Actual implementation of the import. More...
 
ogr::unique_srs importGeoreferencing (OGRDataSourceH data_source)
 
void importStyles (OGRDataSourceH data_source)
 
void importLayer (MapPart *map_part, OGRLayerH layer)
 
void importFeature (MapPart *map_part, OGRFeatureDefnH feature_definition, OGRFeatureH feature, OGRGeometryH geometry)
 
ObjectList importGeometry (OGRFeatureH feature, OGRGeometryH geometry)
 
ObjectList importGeometryCollection (OGRFeatureH feature, OGRGeometryH geometry)
 
ObjectimportPointGeometry (OGRFeatureH feature, OGRGeometryH geometry)
 
PathObjectimportLineStringGeometry (OGRFeatureH feature, OGRGeometryH geometry)
 
PathObjectimportPolygonGeometry (OGRFeatureH feature, OGRGeometryH geometry)
 
SymbolgetSymbol (Symbol::Type type, const char *raw_style_string)
 
MapColormakeColor (OGRStyleToolH tool, const char *color_string)
 
void applyPenColor (OGRStyleToolH tool, LineSymbol *line_symbol)
 
void applyBrushColor (OGRStyleToolH tool, AreaSymbol *area_symbol)
 
MapCoord toMapCoord (double x, double y) const
 
MapCoord fromDrawing (double x, double y) const
 A MapCoordConstructor which interprets the given coordinates in millimeters on paper. More...
 
MapCoord fromProjected (double x, double y) const
 A MapCoordConstructor which interprets the given coordinates as projected. More...
 
- Protected Member Functions inherited from OpenOrienteering::Importer
virtual void prepare ()
 Event handler called from doImport() to prepare the import process. More...
 
virtual void validate ()
 Event handler called from doImport() to complete to postprocess imported data. More...
 
virtual void importFailed ()
 Event handler called from doImport() to complete to cleanup a failed import attempt. More...
 

Static Protected Member Functions

static bool checkGeoreferencing (OGRDataSourceH data_source, const Georeferencing &georef)
 Tests if the file's spatial references can be used with the given georeferencing. More...
 
static LatLon calcAverageLatLon (OGRDataSourceH data_source)
 

Additional Inherited Members

- Protected Attributes inherited from OpenOrienteering::Importer
const QString path
 The input path. More...
 
Map *const map
 The Map to import or export. More...
 
MapView *const view
 The MapView to import or export. More...
 

Detailed Description

An Importer for geospatial vector data supported by OGR.

The option "separate_layers" will cause OGR layers to be imported as distinct map parts if set to true.

Member Typedef Documentation

◆ MapCoordConstructor

using OpenOrienteering::OgrFileImport::MapCoordConstructor = MapCoord (OgrFileImport::*)(double, double) const

A Pointer to a function which creates a MapCoordF from double coordinates.

◆ ObjectList

using OpenOrienteering::OgrFileImport::ObjectList = std::vector<Object*>
protected

Member Enumeration Documentation

◆ UnitType

The unit type indicates the coordinate system the data units refers to.

Enumerator
UnitOnGround 

Data refers to real dimensions. Includes geograghic CS.

UnitOnPaper 

Data refers to dimensions in the (printed) map.

Constructor & Destructor Documentation

◆ OgrFileImport()

OpenOrienteering::OgrFileImport::OgrFileImport ( const QString path,
Map map,
MapView view,
UnitType  unit_type = UnitOnGround 
)

Constructs a new importer.

◆ ~OgrFileImport()

OpenOrienteering::OgrFileImport::~OgrFileImport ( )
overridedefault

Member Function Documentation

◆ applyBrushColor()

void OpenOrienteering::OgrFileImport::applyBrushColor ( OGRStyleToolH  tool,
AreaSymbol area_symbol 
)
protected

◆ applyPenColor()

void OpenOrienteering::OgrFileImport::applyPenColor ( OGRStyleToolH  tool,
LineSymbol line_symbol 
)
protected

◆ calcAverageLatLon() [1/2]

LatLon OpenOrienteering::OgrFileImport::calcAverageLatLon ( const QString path)
static

Calculates the average geographic coordinates (WGS84) of the file.

◆ calcAverageLatLon() [2/2]

LatLon OpenOrienteering::OgrFileImport::calcAverageLatLon ( OGRDataSourceH  data_source)
staticprotected

◆ checkGeoreferencing() [1/2]

bool OpenOrienteering::OgrFileImport::checkGeoreferencing ( const QString path,
const Georeferencing georef 
)
static

Tests if the file's spatial references can be used with the given georeferencing.

This returns true only if all layers' spatial references can be transformed to the spatial reference systems represented by georef. It will always return false for a local or invalid Georeferencing.

◆ checkGeoreferencing() [2/2]

bool OpenOrienteering::OgrFileImport::checkGeoreferencing ( OGRDataSourceH  data_source,
const Georeferencing georef 
)
staticprotected

Tests if the file's spatial references can be used with the given georeferencing.

This returns true only if all layers' spatial references can be transformed to the spatial reference systems represented by georef. It will always return false for a local or invalid Georeferencing.

◆ fromDrawing()

MapCoord OpenOrienteering::OgrFileImport::fromDrawing ( double  x,
double  y 
) const
protected

A MapCoordConstructor which interprets the given coordinates in millimeters on paper.

◆ fromProjected()

MapCoord OpenOrienteering::OgrFileImport::fromProjected ( double  x,
double  y 
) const
protected

A MapCoordConstructor which interprets the given coordinates as projected.

◆ getSymbol()

Symbol * OpenOrienteering::OgrFileImport::getSymbol ( Symbol::Type  type,
const char *  raw_style_string 
)
protected

◆ importFeature()

void OpenOrienteering::OgrFileImport::importFeature ( MapPart map_part,
OGRFeatureDefnH  feature_definition,
OGRFeatureH  feature,
OGRGeometryH  geometry 
)
protected

◆ importGeometry()

OgrFileImport::ObjectList OpenOrienteering::OgrFileImport::importGeometry ( OGRFeatureH  feature,
OGRGeometryH  geometry 
)
protected

◆ importGeometryCollection()

OgrFileImport::ObjectList OpenOrienteering::OgrFileImport::importGeometryCollection ( OGRFeatureH  feature,
OGRGeometryH  geometry 
)
protected

◆ importGeoreferencing()

ogr::unique_srs OpenOrienteering::OgrFileImport::importGeoreferencing ( OGRDataSourceH  data_source)
protected

◆ importImplementation()

bool OpenOrienteering::OgrFileImport::importImplementation ( )
overrideprotectedvirtual

Actual implementation of the import.

This function shall read the input and populate the map and view from it. Importers which support input from QIODevice should use the device(). They must not open or close this device.

If information might be lost in the process, a message shall be recorded by calling addWarning() with a translated, useful description of the issue. If a fatal error is encountered, then this method may either throw an exception, or log an error message with addWarning() and return false. The line between errors and warnings is somewhat of a judgement call on the part of the author, but generally an Importer should not succeed unless the map is populated sufficiently to be useful.

Todo:
Use hooks and delegates per file format

Implements OpenOrienteering::Importer.

◆ importLayer()

void OpenOrienteering::OgrFileImport::importLayer ( MapPart map_part,
OGRLayerH  layer 
)
protected

◆ importLineStringGeometry()

PathObject * OpenOrienteering::OgrFileImport::importLineStringGeometry ( OGRFeatureH  feature,
OGRGeometryH  geometry 
)
protected

◆ importPointGeometry()

Object * OpenOrienteering::OgrFileImport::importPointGeometry ( OGRFeatureH  feature,
OGRGeometryH  geometry 
)
protected

◆ importPolygonGeometry()

PathObject * OpenOrienteering::OgrFileImport::importPolygonGeometry ( OGRFeatureH  feature,
OGRGeometryH  geometry 
)
protected

◆ importStyles()

void OpenOrienteering::OgrFileImport::importStyles ( OGRDataSourceH  data_source)
protected

◆ makeColor()

MapColor * OpenOrienteering::OgrFileImport::makeColor ( OGRStyleToolH  tool,
const char *  color_string 
)
protected

◆ setGeoreferencingImportEnabled()

void OpenOrienteering::OgrFileImport::setGeoreferencingImportEnabled ( bool  enabled)

Enables the import of georeferencing from the geospatial data.

If this import is not enabled, the georeferencing of the Map given to the constructor will be used instead.

◆ srsFromMap()

ogr::unique_srs OpenOrienteering::OgrFileImport::srsFromMap ( )
protected

◆ supportsQIODevice()

bool OpenOrienteering::OgrFileImport::supportsQIODevice ( ) const
overridevirtualnoexcept

Returns true when the importer/exporter supports QIODevice.

The default implementation returns true. Some exporters or importers might wish to use other ways of accessing the output/input path. In these cases, the default implementation should be overwritten to return false.

Reimplemented from OpenOrienteering::ImportExport.

◆ toMapCoord()

MapCoord OpenOrienteering::OgrFileImport::toMapCoord ( double  x,
double  y 
) const
inlineprotected

The documentation for this class was generated from the following files: