35 #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
41 typedef int GNMDirection;
45 #define GNM_MD_NAME "net_name"
46 #define GNM_MD_DESCR "net_description"
47 #define GNM_MD_SRS "net_srs"
48 #define GNM_MD_VERSION "net_version"
49 #define GNM_MD_RULE "net_rule"
50 #define GNM_MD_FORMAT "FORMAT"
51 #define GNM_MD_FETCHEDGES "fetch_edge"
52 #define GNM_MD_FETCHVERTEX "fetch_vertex"
53 #define GNM_MD_NUM_PATHS "num_paths"
54 #define GNM_MD_EMITTER "emitter"
60 { GATDijkstraShortestPath = 1, GATKShortestPath, GATConnectedComponents
64 } GNMGraphAlgorithmType;
66 #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
106 virtual CPLErr Create(
const char *pszFilename,
char **papszOptions) = 0;
119 virtual CPLErr Delete() = 0;
127 virtual const char *GetName()
const;
142 virtual CPLErr DisconnectAll() = 0;
151 virtual OGRFeature *GetFeatureByGlobalFID(GNMGFID nGFID) = 0;
163 virtual OGRLayer *GetPath(GNMGFID nStartFID, GNMGFID nEndFID,
164 GNMGraphAlgorithmType eAlgorithm,
165 char **papszOptions) = 0;
174 virtual int CheckNetworkExist(
const char *pszFilename,
175 char **papszOptions) = 0;
208 char **papszOptions =
nullptr)
override;
216 char **papszOptions)
override = 0;
224 virtual GNMGFID GetNewGlobalFID();
232 virtual CPLString GetAlgorithmName(GNMDirection eAlgorithm,
242 virtual CPLErr AddFeatureGlobalFID(GNMGFID nFID,
const char *pszLayerName);
258 virtual CPLErr ConnectFeatures(GNMGFID nSrcFID, GNMGFID nTgtFID,
259 GNMGFID nConFID = -1,
double dfCost = 1,
260 double dfInvCost = 1,
261 GNMDirection eDir = GNM_EDGE_DIR_BOTH);
270 virtual CPLErr DisconnectFeatures(GNMGFID nSrcFID, GNMGFID nTgtFID,
279 virtual CPLErr DisconnectFeaturesWithId(GNMGFID nFID);
293 virtual CPLErr ReconnectFeatures(GNMGFID nSrcFID, GNMGFID nTgtFID,
294 GNMGFID nConFID,
double dfCost = 1,
295 double dfInvCost = 1,
296 GNMDirection eDir = GNM_EDGE_DIR_BOTH);
336 virtual CPLErr CreateRule(
const char *pszRuleStr);
342 virtual CPLErr DeleteAllRules();
349 virtual CPLErr DeleteRule(
const char *pszRuleStr);
356 virtual char **GetRules()
const;
382 virtual CPLErr ConnectPointsByLines(
char **papszLayerList,
383 double dfTolerance,
double dfCost,
384 double dfInvCost, GNMDirection eDir);
392 virtual CPLErr ChangeBlockState(GNMGFID nFID,
bool bIsBlock);
402 virtual CPLErr ChangeAllBlockState(
bool bIsBlock =
false);
405 GNMGraphAlgorithmType eAlgorithm,
406 char **papszOptions)
override;
415 virtual CPLErr CheckLayerDriver(
const char *pszDefaultDriverName,
416 char **papszOptions);
422 virtual bool CheckStorageDriverSupport(
const char *pszDriverName) = 0;
427 size_t nFieldSize = 1024);
428 virtual CPLErr StoreNetworkSrs();
429 virtual CPLErr LoadNetworkSrs();
434 virtual CPLErr LoadGraph();
436 virtual CPLErr DeleteMetadataLayer() = 0;
437 virtual CPLErr DeleteGraphLayer() = 0;
438 virtual CPLErr DeleteFeaturesLayer() = 0;
439 virtual CPLErr LoadNetworkLayer(
const char *pszLayername) = 0;
440 virtual CPLErr DeleteNetworkLayers() = 0;
441 virtual void ConnectPointsByMultiline(
443 const std::vector<OGRLayer *> &paPointLayers,
double dfTolerance,
444 double dfCost,
double dfInvCost, GNMDirection eDir);
447 const std::vector<OGRLayer *> &paPointLayers,
448 double dfTolerance,
double dfCost,
double dfInvCost,
451 FindNearestPoint(
const OGRPoint *poPoint,
452 const std::vector<OGRLayer *> &paPointLayers,
454 virtual OGRFeature *FindConnection(GNMGFID nSrcFID, GNMGFID nTgtFID,
456 virtual bool SaveRules();
457 virtual GNMGFID GetNewVirtualFID();
459 const GNMPATH &path,
int nNoOfPath,
460 bool bReturnVertices,
bool bReturnEdges);
466 GNMGFID m_nVirtualConnectionGID;
473 std::map<GNMGFID, CPLString> m_moFeatureFIDMap;
474 std::vector<OGRLayer *> m_apoLayers;
475 std::vector<GNMRule> m_asRules;
476 bool m_bIsRulesChanged;
479 bool m_bIsGraphLoaded;
501 double dfMaxX,
double dfMaxY)
override;
505 double dfMinY,
double dfMaxX,
506 double dfMaxY)
override;
516 virtual const char *
GetName()
override;
520 int bExactMatch)
override;
527 int bForce = TRUE)
override;
532 int bApproxOK = TRUE)
override;
536 int nFlagsIn)
override;
539 int bApproxOK = TRUE)
override;
559 char **papszOptions =
nullptr,
560 GDALProgressFunc pfnProgress =
nullptr,
561 void *pProgressArg =
nullptr);
564 char **papszOptions =
nullptr,
565 GDALProgressFunc pfnProgress =
nullptr,
566 void *pProgressArg =
nullptr);
569 char **papszOptions, GDALProgressFunc pfnProgress,
573 char **papszOptions =
nullptr,
574 GDALProgressFunc pfnProgress =
nullptr,
575 void *pProgressArg =
nullptr);
578 char **papszOptions =
nullptr,
579 GDALProgressFunc pfnProgress =
nullptr,
580 void *pProgressArg =
nullptr);
583 char **papszOptions =
nullptr,
584 GDALProgressFunc pfnProgress =
nullptr,
585 void *pProgressArg =
nullptr);
588 char **papszOptions =
nullptr,
589 GDALProgressFunc pfnProgress =
nullptr,
590 void *pProgressArg =
nullptr);
600 OGRErr InitializeIndexSupport(
const char *);
601 OGRLayerAttrIndex *GetIndex();
613 std::map<GNMGFID, GIntBig> m_mnFIDMap;
641 explicit GNMRule(
const std::string &oRule);
643 explicit GNMRule(
const char *pszRule);
655 virtual bool IsValid()
const;
660 virtual bool IsAcceptAny()
const;
666 virtual GNMRuleType GetType()
const;
675 virtual bool CanConnect(
const CPLString &soSrcLayerName,
679 virtual CPLString GetSourceLayerName()
const;
681 virtual CPLString GetTargetLayerName()
const;
683 virtual CPLString GetConnectorLayerName()
const;
685 const char *c_str()
const;
687 operator const char *(void)
const;
691 virtual bool ParseRuleString();
697 bool m_bAllow =
false;
698 bool m_bValid =
false;
725 int bApproxOK = TRUE)
override;
727 int bApproxOK = TRUE)
override;
734 const CPLString &soLayerName,
int nPathNo,
748 #endif // __cplusplus
The OGRGNMWrappedResultLayer class for search paths queries results.
Definition: gnm.h:710
virtual CPLErr Create(const char *pszFilename, char **papszOptions)=0
Create network system layers.
Concrete representation of a multi-vertex line.
Definition: ogr_geometry.h:1682
virtual OGRErr SetIgnoredFields(const char **papszFields) override
Set which fields can be omitted when retrieving features from the layer.
Definition: gnmlayer.cpp:60
virtual OGRStyleTable * GetStyleTable() override
Returns layer style table.
Definition: gnmlayer.cpp:337
Class for dataset open functions.
Definition: gdal_priv.h:277
virtual void ResetReading() override
Reset feature reading to start on the first feature.
Definition: gnmlayer.cpp:211
virtual OGRErr ICreateFeature(OGRFeature *poFeature)
Create and write a new feature within a layer.
Definition: ogrlayer.cpp:648
virtual OGRwkbGeometryType GetGeomType() override
Return the layer geometry type.
Definition: gnmlayer.cpp:261
virtual const char * GetFIDColumn() override
This method returns the name of the underlying database column being used as the FID column,...
Definition: gnmlayer.cpp:50
virtual void ResetReading() override
Reset feature reading to start on the first feature.
Definition: gnmresultlayer.cpp:61
virtual OGRFeature * GetNextFeature() override
Fetch the next available feature from this layer.
Definition: gnmlayer.cpp:216
This class represents a style table.
Definition: ogr_featurestyle.h:84
virtual OGRErr CreateField(OGRFieldDefn *poField, int bApproxOK=TRUE) override
Create a new field on a layer.
Definition: gnmlayer.cpp:297
virtual OGRSpatialReference * GetSpatialRef() override
Fetch the spatial reference system for this layer.
Definition: gnmresultlayer.cpp:118
virtual void SetStyleTable(OGRStyleTable *poStyleTable) override
Set layer style table.
Definition: gnmlayer.cpp:347
The simple graph class, which holds the appropriate for calculations graph in memory (based on STL co...
Definition: gnmgraph.h:89
virtual CPLErr DisconnectAll()=0
DisconnectAll method clears the network graph.
Format specific driver.
Definition: gdal_priv.h:1700
virtual GIntBig GetFeatureCount(int bForce=TRUE) override
Fetch the feature count in this layer.
Definition: gnmresultlayer.cpp:86
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:166
GNM layer which represents a geography network layer of generic format.
Definition: gnm.h:490
virtual void SetSpatialFilterRect(double dfMinX, double dfMinY, double dfMaxX, double dfMaxY) override
Set a new rectangular spatial filter.
Definition: gnmlayer.cpp:188
virtual OGRLayer * GetLayer(int iLayer)
Fetch a layer by index.
Definition: gdaldataset.cpp:7059
virtual OGRErr DeleteField(int iField) override
Delete an existing field on a layer.
Definition: gnmlayer.cpp:302
virtual int TestCapability(const char *) override
Test if this layer supported the named capability.
Definition: gnmlayer.cpp:292
virtual OGRErr GetExtent(OGREnvelope *psExtent, int bForce=TRUE) override
Fetch the extent of this layer.
Definition: gnmlayer.cpp:281
Abstract base class for all geometry classes.
Definition: ogr_geometry.h:334
OGRErr SymDifference(OGRLayer *pLayerMethod, OGRLayer *pLayerResult, char **papszOptions, GDALProgressFunc pfnProgress, void *pProgressArg)
SymDifference.
Definition: gnmlayer.cpp:83
This class represents a layer of simple features, with access methods.
Definition: ogrsf_frmts.h:73
Convenient string class based on std::string.
Definition: cpl_string.h:311
virtual GIntBig GetFeatureCount(int bForce=TRUE) override
Fetch the feature count in this layer.
Definition: gnmlayer.cpp:276
virtual void SetSpatialFilter(OGRGeometry *) override
Set a new spatial filter.
Definition: gnmlayer.cpp:183
Point class.
Definition: ogr_geometry.h:1083
virtual OGRErr ISetFeature(OGRFeature *poFeature)
Rewrite/replace an existing feature.
Definition: ogrlayer.cpp:608
virtual OGRLayer * CopyLayer(OGRLayer *poSrcLayer, const char *pszNewName, char **papszOptions=nullptr)
Duplicate an existing layer.
Definition: gdaldataset.cpp:5242
A set of associated raster bands, usually from one file.
Definition: gdal_priv.h:348
virtual OGRErr CommitTransaction() override
For datasources which support transactions, CommitTransaction commits a transaction.
Definition: gnmlayer.cpp:357
General GNM class which represents a geography network of common format.
Definition: gnm.h:74
virtual OGRErr RollbackTransaction() override
For datasources which support transactions, RollbackTransaction will roll back a datasource to its st...
Definition: gnmlayer.cpp:362
virtual void SetStyleTableDirectly(OGRStyleTable *poStyleTable) override
Set layer style table.
Definition: gnmlayer.cpp:342
virtual OGRLayer * GetPath(GNMGFID nStartFID, GNMGFID nEndFID, GNMGraphAlgorithmType eAlgorithm, char **papszOptions)=0
Create path between start and end GFIDs.
A collection of OGRLineString.
Definition: ogr_geometry.h:3812
virtual OGRErr SetAttributeFilter(const char *) override
Set a new attribute query.
Definition: gnmlayer.cpp:206
OGRErr Erase(OGRLayer *pLayerMethod, OGRLayer *pLayerResult, char **papszOptions=nullptr, GDALProgressFunc pfnProgress=nullptr, void *pProgressArg=nullptr)
Erase.
Definition: gnmlayer.cpp:118
virtual int GetVersion() const
GetVersion return the network version if applicable.
Definition: gnm.h:133
static GDALDataset * Open(const char *pszFilename, unsigned int nOpenFlags=0, const char *const *papszAllowedDrivers=nullptr, const char *const *papszOpenOptions=nullptr, const char *const *papszSiblingFiles=nullptr)
Definition: gdal_priv.h:703
virtual OGRErr CreateGeomField(OGRGeomFieldDefn *poField, int bApproxOK=TRUE) override
Create a new geometry field on a layer.
Definition: gnmlayer.cpp:326
virtual int FindFieldIndex(const char *pszFieldName, int bExactMatch) override
Find the index of field in the layer.
Definition: gnmlayer.cpp:266
virtual const char * GetGeometryColumn() override
This method returns the name of the underlying database column being used as the geometry column,...
Definition: gnmresultlayer.cpp:113
GIntBig GetFeaturesRead()
GetFeaturesRead.
Definition: gnmlayer.cpp:126
virtual OGRErr SyncToDisk() override
Flush pending changes to disk.
Definition: gnmlayer.cpp:332
GNMGenericLayer(OGRLayer *poLayer, GNMGenericNetwork *poNetwork)
GNMGenericLayer.
Definition: gnmlayer.cpp:36
virtual OGRFeatureDefn * GetLayerDefn() override
Fetch the schema information for this layer.
Definition: gnmresultlayer.cpp:81
Definition of an attribute of an OGRFeatureDefn.
Definition: ogr_feature.h:103
virtual const char * GetFIDColumn() override
This method returns the name of the underlying database column being used as the FID column,...
Definition: gnmresultlayer.cpp:108
virtual int TestCapability(const char *pszCap) override
Test if this layer supported the named capability.
Definition: gnmresultlayer.cpp:91
virtual OGRErr DeleteFeature(GIntBig nFID) override
Delete feature from layer.
Definition: gnmlayer.cpp:232
virtual int CloseDependentDatasets()
Drop references to any other datasets referenced by this dataset.
Definition: gdaldataset.cpp:4272
Definition of a geometry field of an OGRFeatureDefn.
Definition: ogr_feature.h:286
OGRGNMWrappedResultLayer(GDALDataset *poDS, OGRLayer *poLayer)
Constructor.
Definition: gnmresultlayer.cpp:34
virtual OGRFeature * GetNextFeature() override
Fetch the next available feature from this layer.
Definition: gnmresultlayer.cpp:66
virtual OGRFeatureDefn * GetLayerDefn() override
Fetch the schema information for this layer.
Definition: gnmlayer.cpp:367
virtual ~GNMGenericLayer()
~GNMGenericLayer
Definition: gnmlayer.cpp:46
virtual OGRErr CreateField(OGRFieldDefn *poField, int bApproxOK=TRUE) override
Create a new field on a layer.
Definition: gnmresultlayer.cpp:96
int OGRErr
Type for a OGR error.
Definition: ogr_core.h:378
virtual const OGRSpatialReference * GetSpatialRef() const
Fetch the spatial reference for this dataset.
Definition: gdaldataset.cpp:1097
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:226
virtual char ** GetFileList(void)
Fetch files forming dataset.
Definition: gdaldataset.cpp:3117
OGRwkbGeometryType
List of well known binary geometry types.
Definition: ogr_core.h:406
virtual const char * GetGeometryColumn() override
This method returns the name of the underlying database column being used as the geometry column,...
Definition: gnmlayer.cpp:55
virtual OGRFeature * GetFeatureByGlobalFID(GNMGFID nGFID)=0
GetFeatureByGlobalFID search all network layers for given feature identificator.
OGRErr Intersection(OGRLayer *pLayerMethod, OGRLayer *pLayerResult, char **papszOptions=nullptr, GDALProgressFunc pfnProgress=nullptr, void *pProgressArg=nullptr)
Intersection.
Definition: gnmlayer.cpp:65
virtual OGRErr SetNextByIndex(GIntBig nIndex) override
Move read cursor to the nIndex'th feature in the current resultset.
Definition: gnmlayer.cpp:227
A simple feature, including geometry and attributes.
Definition: ogr_feature.h:680
OGRErr Clip(OGRLayer *pLayerMethod, OGRLayer *pLayerResult, char **papszOptions=nullptr, GDALProgressFunc pfnProgress=nullptr, void *pProgressArg=nullptr)
Clip.
Definition: gnmlayer.cpp:110
virtual OGRErr ICreateFeature(OGRFeature *poFeature) override
Create and write a new feature within a layer.
Definition: gnmresultlayer.cpp:215
virtual int GetLayerCount()
Get the number of layers in this dataset.
Definition: gdaldataset.cpp:7029
OGRErr Union(OGRLayer *pLayerMethod, OGRLayer *pLayerResult, char **papszOptions=nullptr, GDALProgressFunc pfnProgress=nullptr, void *pProgressArg=nullptr)
Union.
Definition: gnmlayer.cpp:75
CPLErr
Error category.
Definition: cpl_error.h:52
OGRErr Identity(OGRLayer *pLayerMethod, OGRLayer *pLayerResult, char **papszOptions=nullptr, GDALProgressFunc pfnProgress=nullptr, void *pProgressArg=nullptr)
Identity.
Definition: gnmlayer.cpp:93
virtual OGRFeature * GetFeature(GIntBig nFID) override
Fetch a feature by its identifier.
Definition: gnmresultlayer.cpp:76
virtual OGRErr InsertFeature(OGRFeature *poFeature, const CPLString &soLayerName, int nPathNo, bool bIsEdge)
Undocumented.
Definition: gnmresultlayer.cpp:124
int AttributeFilterEvaluationNeedsGeometry()
AttributeFilterEvaluationNeedsGeometry.
Definition: gnmlayer.cpp:131
virtual OGRErr ISetFeature(OGRFeature *poFeature) override
Rewrite/replace an existing feature.
Definition: gnmresultlayer.cpp:210
OGRErr Update(OGRLayer *pLayerMethod, OGRLayer *pLayerResult, char **papszOptions=nullptr, GDALProgressFunc pfnProgress=nullptr, void *pProgressArg=nullptr)
Update.
Definition: gnmlayer.cpp:102
Simple container for a bounding region (rectangle)
Definition: ogr_core.h:57
virtual OGRErr StartTransaction() override
For datasources which support transactions, StartTransaction creates a transaction.
Definition: gnmlayer.cpp:352
Definition of a feature class or feature layer.
Definition: ogr_feature.h:385
virtual int TestCapability(const char *)
Test if capability is available.
Definition: gdaldataset.cpp:7418
virtual OGRErr ReorderFields(int *panMap) override
Reorder all the fields of a layer.
Definition: gnmlayer.cpp:311
virtual const char * GetName() override
Return the layer name.
Definition: gnmlayer.cpp:256
virtual OGRErr CreateGeomField(OGRGeomFieldDefn *poField, int bApproxOK=TRUE) override
Create a new geometry field on a layer.
Definition: gnmresultlayer.cpp:102
GNM class which represents a geography network of generic format.
Definition: gnm.h:193
virtual OGRSpatialReference * GetSpatialRef() override
Fetch the spatial reference system for this layer.
Definition: gnmlayer.cpp:271
The simple class for rules.
Definition: gnm.h:631
virtual OGRErr SetNextByIndex(GIntBig nIndex) override
Move read cursor to the nIndex'th feature in the current resultset.
Definition: gnmresultlayer.cpp:71
virtual OGRGeometry * GetSpatialFilter() override
This method returns the current spatial filter for this layer.
Definition: gnmlayer.cpp:178
virtual CPLErr FlushCache(bool bAtClosing=false)
Flush all write cached data to disk.
Definition: gdaldataset.cpp:556
virtual OGRErr DeleteLayer(int iLayer)
Delete the indicated layer from the datasource.
Definition: gdaldataset.cpp:5580
virtual OGRErr AlterFieldDefn(int iField, OGRFieldDefn *poNewFieldDefn, int nFlagsIn) override
Alter the definition of an existing field on a layer.
Definition: gnmlayer.cpp:316
virtual CPLErr Delete()=0
Delete network.