GDAL
gnm.h
1/******************************************************************************
2 *
3 * Project: GDAL/OGR Geography Network support (Geographic Network Model)
4 * Purpose: GNM general public declarations.
5 * Authors: Mikhail Gusev (gusevmihs at gmail dot com)
6 * Dmitry Baryshnikov, polimax@mail.ru
7 *
8 ******************************************************************************
9 * Copyright (c) 2014, Mikhail Gusev
10 * Copyright (c) 2014-2015, NextGIS <info@nextgis.com>
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28 * DEALINGS IN THE SOFTWARE.
29 ****************************************************************************/
30
31#ifndef GNM
32#define GNM
33
34#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
35#include "ogrsf_frmts.h"
36#endif
37#include "gnmgraph.h"
38
39// Direction of an edge.
40typedef int GNMDirection; // We use int values in order to save them to the
41 // network data.
42
43// Network's metadata parameters names.
44#define GNM_MD_NAME "net_name"
45#define GNM_MD_DESCR "net_description"
46#define GNM_MD_SRS "net_srs"
47#define GNM_MD_VERSION "net_version"
48#define GNM_MD_RULE "net_rule"
49#define GNM_MD_FORMAT "FORMAT"
50#define GNM_MD_FETCHEDGES "fetch_edge"
51#define GNM_MD_FETCHVERTEX "fetch_vertex"
52#define GNM_MD_NUM_PATHS "num_paths"
53#define GNM_MD_EMITTER "emitter"
54
55// TODO: Constants for capabilities.
56// #define GNMCanChangeConnections "CanChangeConnections"
57
58typedef enum
59{
GATDijkstraShortestPath = 1, GATKShortestPath, GATConnectedComponents
63} GNMGraphAlgorithmType;
64
65#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
66
73class CPL_DLL GNMNetwork : public GDALDataset
74{
75 public:
76 GNMNetwork();
77 ~GNMNetwork() override;
78
79 // GDALDataset Interface
80 const OGRSpatialReference *GetSpatialRef() const override;
81 char **GetFileList(void) override;
82
83 // GNMNetwork Interface
84
105 virtual CPLErr Create(const char *pszFilename,
106 CSLConstList papszOptions) = 0;
107
113 virtual CPLErr Open(GDALOpenInfo *poOpenInfo) = 0;
114
119 virtual CPLErr Delete() = 0;
120
127 virtual const char *GetName() const;
128
133 virtual int GetVersion() const
134 {
135 return 0;
136 }
137
142 virtual CPLErr DisconnectAll() = 0;
143
151 virtual OGRFeature *GetFeatureByGlobalFID(GNMGFID nGFID) = 0;
152
163 virtual OGRLayer *GetPath(GNMGFID nStartFID, GNMGFID nEndFID,
164 GNMGraphAlgorithmType eAlgorithm,
165 CSLConstList papszOptions) = 0;
166
169 {
170 return static_cast<GNMNetwork *>(hNet);
171 }
172
174 static inline GNMGenericNetworkH ToHandle(GNMNetwork *poNetwork)
175 {
176 return static_cast<GNMGenericNetworkH>(poNetwork);
177 }
178
179 protected:
186 virtual int CheckNetworkExist(const char *pszFilename,
187 CSLConstList papszOptions) = 0;
188
189 protected:
191 CPLString m_soName{};
192 OGRSpatialReference m_oSRS{};
194};
195
196class GNMRule;
198
205class CPL_DLL GNMGenericNetwork : public GNMNetwork
206{
207 public:
209 ~GNMGenericNetwork() override;
210
211 // GDALDataset Interface
212
213 int GetLayerCount() const override;
214 OGRLayer *GetLayer(int) const override;
215 OGRErr DeleteLayer(int) override;
216
217 int TestCapability(const char *) const override;
218
219 virtual OGRLayer *CopyLayer(OGRLayer *poSrcLayer, const char *pszNewName,
220 CSLConstList papszOptions = nullptr) override;
221
223 CPLErr FlushCache(bool bAtClosing) override;
224
225 // GNMNetwork Interface
226
227 virtual CPLErr Create(const char *pszFilename,
228 CSLConstList papszOptions) override = 0;
229 CPLErr Delete() override;
230
231 int GetVersion() const override;
236 virtual GNMGFID GetNewGlobalFID();
237
244 virtual CPLString GetAlgorithmName(GNMDirection eAlgorithm,
245 bool bShortName);
246
254 virtual CPLErr AddFeatureGlobalFID(GNMGFID nFID, const char *pszLayerName);
255
270 virtual CPLErr ConnectFeatures(GNMGFID nSrcFID, GNMGFID nTgtFID,
271 GNMGFID nConFID = -1, double dfCost = 1,
272 double dfInvCost = 1,
273 GNMDirection eDir = GNM_EDGE_DIR_BOTH);
274
282 virtual CPLErr DisconnectFeatures(GNMGFID nSrcFID, GNMGFID nTgtFID,
283 GNMGFID nConFID);
284
291 virtual CPLErr DisconnectFeaturesWithId(GNMGFID nFID);
292
305 virtual CPLErr ReconnectFeatures(GNMGFID nSrcFID, GNMGFID nTgtFID,
306 GNMGFID nConFID, double dfCost = 1,
307 double dfInvCost = 1,
308 GNMDirection eDir = GNM_EDGE_DIR_BOTH);
309
311
312 OGRFeature *GetFeatureByGlobalFID(GNMGFID nFID) override;
313
348 virtual CPLErr CreateRule(const char *pszRuleStr);
349
355
361 virtual CPLErr DeleteRule(const char *pszRuleStr);
362
368 virtual char **GetRules() const;
369
394 virtual CPLErr ConnectPointsByLines(char **papszLayerList,
395 double dfTolerance, double dfCost,
396 double dfInvCost, GNMDirection eDir);
397
404 virtual CPLErr ChangeBlockState(GNMGFID nFID, bool bIsBlock);
405
414 virtual CPLErr ChangeAllBlockState(bool bIsBlock = false);
415
416 virtual OGRLayer *GetPath(GNMGFID nStartFID, GNMGFID nEndFID,
417 GNMGraphAlgorithmType eAlgorithm,
418 CSLConstList papszOptions) override;
419
422 {
423 return static_cast<GNMGenericNetwork *>(hNet);
424 }
425
428 {
429 return static_cast<GNMGenericNetworkH>(poNetwork);
430 }
431
432 protected:
439 virtual CPLErr CheckLayerDriver(const char *pszDefaultDriverName,
440 CSLConstList papszOptions);
446 virtual bool CheckStorageDriverSupport(const char *pszDriverName) = 0;
447
448 protected:
450 virtual CPLErr CreateMetadataLayer(GDALDataset *const pDS, int nVersion,
451 size_t nFieldSize = 1024);
452 virtual CPLErr StoreNetworkSrs();
453 virtual CPLErr LoadNetworkSrs();
454 virtual CPLErr CreateGraphLayer(GDALDataset *const pDS);
455 virtual CPLErr CreateFeaturesLayer(GDALDataset *const pDS);
456 virtual CPLErr LoadMetadataLayer(GDALDataset *const pDS);
457 virtual CPLErr LoadGraphLayer(GDALDataset *const pDS);
458 virtual CPLErr LoadGraph();
459 virtual CPLErr LoadFeaturesLayer(GDALDataset *const pDS);
460 virtual CPLErr DeleteMetadataLayer() = 0;
461 virtual CPLErr DeleteGraphLayer() = 0;
462 virtual CPLErr DeleteFeaturesLayer() = 0;
463 virtual CPLErr LoadNetworkLayer(const char *pszLayername) = 0;
464 virtual CPLErr DeleteNetworkLayers() = 0;
465 virtual void ConnectPointsByMultiline(
466 GIntBig nFID, const OGRMultiLineString *poMultiLineString,
467 const std::vector<OGRLayer *> &paPointLayers, double dfTolerance,
468 double dfCost, double dfInvCost, GNMDirection eDir);
469 virtual void
470 ConnectPointsByLine(GIntBig nFID, const OGRLineString *poLineString,
471 const std::vector<OGRLayer *> &paPointLayers,
472 double dfTolerance, double dfCost, double dfInvCost,
473 GNMDirection eDir);
474 virtual GNMGFID
475 FindNearestPoint(const OGRPoint *poPoint,
476 const std::vector<OGRLayer *> &paPointLayers,
477 double dfTolerance);
478 virtual OGRFeature *FindConnection(GNMGFID nSrcFID, GNMGFID nTgtFID,
479 GNMGFID nConFID);
480 virtual bool SaveRules();
481 virtual GNMGFID GetNewVirtualFID();
482 virtual void FillResultLayer(OGRGNMWrappedResultLayer *poResLayer,
483 const GNMPATH &path, int nNoOfPath,
484 bool bReturnVertices, bool bReturnEdges);
486 protected:
488 int m_nVersion = 0;
489 GNMGFID m_nGID = 0;
490 GNMGFID m_nVirtualConnectionGID = -1;
491 OGRLayer *m_poMetadataLayer = nullptr;
492 OGRLayer *m_poGraphLayer = nullptr;
493 OGRLayer *m_poFeaturesLayer = nullptr;
494
495 GDALDriver *m_poLayerDriver = nullptr;
496
497 std::map<GNMGFID, CPLString> m_moFeatureFIDMap{};
498 std::vector<OGRLayer *> m_apoLayers{};
499 std::vector<GNMRule> m_asRules;
500 bool m_bIsRulesChanged = false;
501
502 GNMGraph m_oGraph{};
503 bool m_bIsGraphLoaded = false;
505 private:
507};
508
516class GNMGenericLayer final : public OGRLayer
517{
518 public:
519 GNMGenericLayer(OGRLayer *poLayer, GNMGenericNetwork *poNetwork);
521
522 // OGRLayer Interface
523
524 OGRGeometry *GetSpatialFilter() override;
525
526 virtual OGRErr ISetSpatialFilter(int iGeomField,
527 const OGRGeometry *) override;
528
529 OGRErr SetAttributeFilter(const char *) override;
530
531 void ResetReading() override;
532 OGRFeature *GetNextFeature() override;
533 OGRErr SetNextByIndex(GIntBig nIndex) override;
534
535 OGRErr DeleteFeature(GIntBig nFID) override;
536
537 const char *GetName() const override;
538 OGRwkbGeometryType GetGeomType() const override;
539 const OGRFeatureDefn *GetLayerDefn() const override;
540 virtual int FindFieldIndex(const char *pszFieldName,
541 int bExactMatch) override;
542
543 const OGRSpatialReference *GetSpatialRef() const override;
544
545 GIntBig GetFeatureCount(int bForce = TRUE) override;
546
547 virtual OGRErr IGetExtent(int iGeomField, OGREnvelope *psExtent,
548 bool bForce = true) override;
549
550 int TestCapability(const char *) const override;
551
552 virtual OGRErr CreateField(const OGRFieldDefn *poField,
553 int bApproxOK = TRUE) override;
554 OGRErr DeleteField(int iField) override;
555 OGRErr ReorderFields(int *panMap) override;
556 virtual OGRErr AlterFieldDefn(int iField, OGRFieldDefn *poNewFieldDefn,
557 int nFlagsIn) override;
558
559 virtual OGRErr CreateGeomField(const OGRGeomFieldDefn *poField,
560 int bApproxOK = TRUE) override;
561
562 OGRErr SyncToDisk() override;
563
564 OGRStyleTable *GetStyleTable() override;
565 void SetStyleTableDirectly(OGRStyleTable *poStyleTable) override;
566
567 void SetStyleTable(OGRStyleTable *poStyleTable) override;
568
569 OGRErr StartTransaction() override;
570 OGRErr CommitTransaction() override;
571 OGRErr RollbackTransaction() override;
572
573 const char *GetFIDColumn() const override;
574 const char *GetGeometryColumn() const override;
575
576 OGRErr SetIgnoredFields(CSLConstList papszFields) override;
577
579 OGRErr Intersection(OGRLayer *pLayerMethod, OGRLayer *pLayerResult,
580 CSLConstList papszOptions = nullptr,
581 GDALProgressFunc pfnProgress = nullptr,
582 void *pProgressArg = nullptr);
584 OGRErr Union(OGRLayer *pLayerMethod, OGRLayer *pLayerResult,
585 CSLConstList papszOptions = nullptr,
586 GDALProgressFunc pfnProgress = nullptr,
587 void *pProgressArg = nullptr);
589 OGRErr SymDifference(OGRLayer *pLayerMethod, OGRLayer *pLayerResult,
590 CSLConstList papszOptions,
591 GDALProgressFunc pfnProgress, void *pProgressArg);
593 OGRErr Identity(OGRLayer *pLayerMethod, OGRLayer *pLayerResult,
594 CSLConstList papszOptions = nullptr,
595 GDALProgressFunc pfnProgress = nullptr,
596 void *pProgressArg = nullptr);
598 OGRErr Update(OGRLayer *pLayerMethod, OGRLayer *pLayerResult,
599 CSLConstList papszOptions = nullptr,
600 GDALProgressFunc pfnProgress = nullptr,
601 void *pProgressArg = nullptr);
603 OGRErr Clip(OGRLayer *pLayerMethod, OGRLayer *pLayerResult,
604 CSLConstList papszOptions = nullptr,
605 GDALProgressFunc pfnProgress = nullptr,
606 void *pProgressArg = nullptr);
608 OGRErr Erase(OGRLayer *pLayerMethod, OGRLayer *pLayerResult,
609 CSLConstList papszOptions = nullptr,
610 GDALProgressFunc pfnProgress = nullptr,
611 void *pProgressArg = nullptr);
612
615
618
620 /* consider these private */
621 OGRErr InitializeIndexSupport(const char *);
622 OGRLayerAttrIndex *GetIndex();
624
625 protected:
627 OGRErr ISetFeature(OGRFeature *poFeature) override;
628 OGRErr ICreateFeature(OGRFeature *poFeature) override;
629
630 protected:
631 CPLString m_soLayerName{};
632 OGRLayer *m_poLayer = nullptr;
633 GNMGenericNetwork *m_poNetwork = nullptr;
634 std::map<GNMGFID, GIntBig> m_mnFIDMap{};
636
637 private:
639};
640
641typedef enum
642{
GRTConnection = 0
644} GNMRuleType;
645
655class CPL_DLL GNMRule /* non final */
656{
657 public:
661 explicit GNMRule(const std::string &oRule);
663 explicit GNMRule(const char *pszRule);
664
666 GNMRule(const GNMRule &) = default;
667
669 GNMRule(GNMRule &&) = default;
670
672 GNMRule &operator=(const GNMRule &) = default;
673
675 GNMRule &operator=(GNMRule &&) = default;
676
678 virtual ~GNMRule();
679
684 virtual bool IsValid() const;
689 virtual bool IsAcceptAny() const;
695 virtual GNMRuleType GetType() const;
704 virtual bool CanConnect(const CPLString &soSrcLayerName,
705 const CPLString &soTgtLayerName,
706 const CPLString &soConnLayerName = "");
714 const char *c_str() const;
716 operator const char *(void) const;
717
718 protected:
720 virtual bool ParseRuleString();
721
722 protected:
723 CPLString m_soSrcLayerName{};
724 CPLString m_soTgtLayerName{};
725 CPLString m_soConnLayerName{};
726 bool m_bAllow = false;
727 bool m_bValid = false;
728 bool m_bAny = false;
729 CPLString m_soRuleString{};
731};
732
740{
741 public:
743 ~OGRGNMWrappedResultLayer() override;
744
745 // OGRLayer
746 void ResetReading() override;
747 OGRFeature *GetNextFeature() override;
748 OGRErr SetNextByIndex(GIntBig nIndex) override;
749 OGRFeature *GetFeature(GIntBig nFID) override;
750 const OGRFeatureDefn *GetLayerDefn() const override;
751 GIntBig GetFeatureCount(int bForce = TRUE) override;
752 int TestCapability(const char *pszCap) const override;
753 virtual OGRErr CreateField(const OGRFieldDefn *poField,
754 int bApproxOK = TRUE) override;
755 virtual OGRErr CreateGeomField(const OGRGeomFieldDefn *poField,
756 int bApproxOK = TRUE) override;
757 const char *GetFIDColumn() const override;
758 const char *GetGeometryColumn() const override;
759 const OGRSpatialReference *GetSpatialRef() const override;
760
761 // OGRGNMWrappedResultLayer
762 OGRErr InsertFeature(OGRFeature *poFeature, const CPLString &soLayerName,
763 int nPathNo, bool bIsEdge);
764
765 protected:
766 OGRErr ISetFeature(OGRFeature *poFeature) override;
767 OGRErr ICreateFeature(OGRFeature *poFeature) override;
768
769 protected:
771 GDALDataset *poDS = nullptr;
772 OGRLayer *poLayer = nullptr;
774
775 private:
777};
778
779#endif // __cplusplus
780
781#endif // GNM
Convenient string class based on std::string.
Definition cpl_string.h:338
A set of associated raster bands, usually from one file.
Definition gdal_dataset.h:77
virtual const OGRSpatialReference * GetSpatialRef() const
Fetch the spatial reference for this dataset.
Definition gdaldataset.cpp:1374
virtual char ** GetFileList(void)
Fetch files forming dataset.
Definition gdaldataset.cpp:3690
Format specific driver.
Definition gdal_driver.h:63
Class for dataset open functions.
Definition gdal_openinfo.h:30
GNM layer which represents a geography network layer of generic format.
Definition gnm.h:517
const OGRSpatialReference * GetSpatialRef() const override
Fetch the spatial reference system for this layer.
Definition gnmlayer.cpp:254
OGRErr ReorderFields(int *panMap) override
Reorder all the fields of a layer.
Definition gnmlayer.cpp:289
~GNMGenericLayer() override
~GNMGenericLayer
void SetStyleTable(OGRStyleTable *poStyleTable) override
Set layer style table.
Definition gnmlayer.cpp:325
int TestCapability(const char *) const override
Test if this layer supported the named capability.
Definition gnmlayer.cpp:270
const char * GetGeometryColumn() const override
This method returns the name of the underlying database column being used as the geometry column,...
Definition gnmlayer.cpp:53
OGRErr SyncToDisk() override
Flush pending changes to disk.
Definition gnmlayer.cpp:310
virtual int FindFieldIndex(const char *pszFieldName, int bExactMatch) override
Find the index of field in the layer.
Definition gnmlayer.cpp:249
GIntBig GetFeatureCount(int bForce=TRUE) override
Fetch the feature count in this layer.
Definition gnmlayer.cpp:259
void ResetReading() override
Reset feature reading to start on the first feature.
Definition gnmlayer.cpp:193
OGRErr RollbackTransaction() override
For datasources which support transactions, RollbackTransaction will roll back a datasource to its st...
Definition gnmlayer.cpp:340
OGRwkbGeometryType GetGeomType() const override
Return the layer geometry type.
Definition gnmlayer.cpp:244
OGRStyleTable * GetStyleTable() override
Returns layer style table.
Definition gnmlayer.cpp:315
virtual OGRErr IGetExtent(int iGeomField, OGREnvelope *psExtent, bool bForce=true) override
Fetch the extent of this layer, on the specified geometry field.
Definition gnmlayer.cpp:264
OGRErr SetNextByIndex(GIntBig nIndex) override
Move read cursor to the nIndex'th feature in the current resultset.
Definition gnmlayer.cpp:209
virtual OGRErr AlterFieldDefn(int iField, OGRFieldDefn *poNewFieldDefn, int nFlagsIn) override
Alter the definition of an existing field on a layer.
Definition gnmlayer.cpp:294
OGRErr Clip(OGRLayer *pLayerMethod, OGRLayer *pLayerResult, CSLConstList papszOptions=nullptr, GDALProgressFunc pfnProgress=nullptr, void *pProgressArg=nullptr)
Clip.
Definition gnmlayer.cpp:108
OGRErr DeleteField(int iField) override
Delete an existing field on a layer.
Definition gnmlayer.cpp:280
virtual OGRErr CreateGeomField(const OGRGeomFieldDefn *poField, int bApproxOK=TRUE) override
Create a new geometry field on a layer.
Definition gnmlayer.cpp:304
OGRErr SetIgnoredFields(CSLConstList papszFields) override
Set which fields can be omitted when retrieving features from the layer.
Definition gnmlayer.cpp:58
const char * GetName() const override
Return the layer name.
Definition gnmlayer.cpp:239
OGRErr Update(OGRLayer *pLayerMethod, OGRLayer *pLayerResult, CSLConstList papszOptions=nullptr, GDALProgressFunc pfnProgress=nullptr, void *pProgressArg=nullptr)
Update.
Definition gnmlayer.cpp:100
OGRFeature * GetNextFeature() override
Fetch the next available feature from this layer.
Definition gnmlayer.cpp:198
OGRErr CommitTransaction() override
For datasources which support transactions, CommitTransaction commits a transaction.
Definition gnmlayer.cpp:335
GIntBig GetFeaturesRead()
GetFeaturesRead.
Definition gnmlayer.cpp:124
OGRErr Intersection(OGRLayer *pLayerMethod, OGRLayer *pLayerResult, CSLConstList papszOptions=nullptr, GDALProgressFunc pfnProgress=nullptr, void *pProgressArg=nullptr)
Intersection.
Definition gnmlayer.cpp:63
OGRErr Erase(OGRLayer *pLayerMethod, OGRLayer *pLayerResult, CSLConstList papszOptions=nullptr, GDALProgressFunc pfnProgress=nullptr, void *pProgressArg=nullptr)
Erase.
Definition gnmlayer.cpp:116
const OGRFeatureDefn * GetLayerDefn() const override
Fetch the schema information for this layer.
Definition gnmlayer.cpp:345
OGRErr StartTransaction() override
For datasources which support transactions, StartTransaction creates a transaction.
Definition gnmlayer.cpp:330
const char * GetFIDColumn() const override
This method returns the name of the underlying database column being used as the FID column,...
Definition gnmlayer.cpp:48
OGRErr SetAttributeFilter(const char *) override
Set a new attribute query.
Definition gnmlayer.cpp:188
virtual OGRErr CreateField(const OGRFieldDefn *poField, int bApproxOK=TRUE) override
Create a new field on a layer.
Definition gnmlayer.cpp:275
OGRGeometry * GetSpatialFilter() override
This method returns the current spatial filter for this layer.
Definition gnmlayer.cpp:177
virtual OGRErr ISetSpatialFilter(int iGeomField, const OGRGeometry *) override
Set a new spatial filter.
Definition gnmlayer.cpp:182
OGRErr SymDifference(OGRLayer *pLayerMethod, OGRLayer *pLayerResult, CSLConstList papszOptions, GDALProgressFunc pfnProgress, void *pProgressArg)
SymDifference.
Definition gnmlayer.cpp:81
int AttributeFilterEvaluationNeedsGeometry()
AttributeFilterEvaluationNeedsGeometry.
Definition gnmlayer.cpp:129
void SetStyleTableDirectly(OGRStyleTable *poStyleTable) override
Set layer style table.
Definition gnmlayer.cpp:320
OGRErr DeleteFeature(GIntBig nFID) override
Delete feature from layer.
Definition gnmlayer.cpp:214
OGRErr Union(OGRLayer *pLayerMethod, OGRLayer *pLayerResult, CSLConstList papszOptions=nullptr, GDALProgressFunc pfnProgress=nullptr, void *pProgressArg=nullptr)
Union.
Definition gnmlayer.cpp:73
OGRErr Identity(OGRLayer *pLayerMethod, OGRLayer *pLayerResult, CSLConstList papszOptions=nullptr, GDALProgressFunc pfnProgress=nullptr, void *pProgressArg=nullptr)
Identity.
Definition gnmlayer.cpp:91
GNM class which represents a geography network of generic format.
Definition gnm.h:206
int TestCapability(const char *) const override
Test if capability is available.
virtual CPLErr AddFeatureGlobalFID(GNMGFID nFID, const char *pszLayerName)
AddFeatureGlobalFID add the FID <-> Layer name link to fast access features by global FID.
virtual OGRLayer * GetPath(GNMGFID nStartFID, GNMGFID nEndFID, GNMGraphAlgorithmType eAlgorithm, CSLConstList papszOptions) override
Create path between start and end GFIDs.
static GNMGenericNetwork * FromHandle(GNMGenericNetworkH hNet)
Casts a handle to a pointer.
Definition gnm.h:421
virtual CPLErr DeleteRule(const char *pszRuleStr)
Delete the specified rule.
virtual char ** GetRules() const
Get the rule list.
virtual OGRLayer * CopyLayer(OGRLayer *poSrcLayer, const char *pszNewName, CSLConstList papszOptions=nullptr) override
Duplicate an existing layer.
OGRFeature * GetFeatureByGlobalFID(GNMGFID nFID) override
GetFeatureByGlobalFID search all network layers for given feature identificator.
virtual CPLErr DeleteAllRules()
Delete all rules from network.
OGRErr DeleteLayer(int) override
Delete the indicated layer from the datasource.
virtual CPLErr ReconnectFeatures(GNMGFID nSrcFID, GNMGFID nTgtFID, GNMGFID nConFID, double dfCost=1, double dfInvCost=1, GNMDirection eDir=GNM_EDGE_DIR_BOTH)
Change connection attributes.
virtual CPLString GetAlgorithmName(GNMDirection eAlgorithm, bool bShortName)
Get the algorithm name.
OGRLayer * GetLayer(int) const override
Fetch a layer by index.
virtual CPLErr ConnectFeatures(GNMGFID nSrcFID, GNMGFID nTgtFID, GNMGFID nConFID=-1, double dfCost=1, double dfInvCost=1, GNMDirection eDir=GNM_EDGE_DIR_BOTH)
Connects two features via third feature (may be virtual, so the identificator should be -1).
virtual CPLErr DisconnectFeaturesWithId(GNMGFID nFID)
Find the corresponding identificator in graph (source, target, connector) and remove such connections...
int GetLayerCount() const override
Get the number of layers in this dataset.
virtual CPLErr ChangeAllBlockState(bool bIsBlock=false)
Change all vertices and edges block state.
virtual CPLErr DisconnectFeatures(GNMGFID nSrcFID, GNMGFID nTgtFID, GNMGFID nConFID)
Remove features connection.
virtual bool CheckStorageDriverSupport(const char *pszDriverName)=0
Check if provided OGR driver accepted as storage for network data.
static GNMGenericNetworkH ToHandle(GNMGenericNetwork *poNetwork)
Casts a pointer to a handle.
Definition gnm.h:427
CPLErr DisconnectAll() override
DisconnectAll method clears the network graph.
CPLErr FlushCache(bool bAtClosing) override
Flush all write cached data to disk.
virtual GNMGFID GetNewGlobalFID()
GetNewGlobalFID increase the global ID counter.
virtual CPLErr CreateRule(const char *pszRuleStr)
Create network rule.
int GetVersion() const override
GetVersion return the network version if applicable.
virtual CPLErr CheckLayerDriver(const char *pszDefaultDriverName, CSLConstList papszOptions)
Check or create layer OGR driver.
virtual CPLErr ConnectPointsByLines(char **papszLayerList, double dfTolerance, double dfCost, double dfInvCost, GNMDirection eDir)
Attempts to build the network topology automatically.
int CloseDependentDatasets() override
Drop references to any other datasets referenced by this dataset.
virtual CPLErr ChangeBlockState(GNMGFID nFID, bool bIsBlock)
Change the block state of edge or vertex.
virtual CPLErr Create(const char *pszFilename, CSLConstList papszOptions) override=0
Create network system layers.
CPLErr Delete() override
Delete network.
The simple graph class, which holds the appropriate for calculations graph in memory (based on STL co...
Definition gnmgraph.h:89
General GNM class which represents a geography network of common format.
Definition gnm.h:74
virtual CPLErr Delete()=0
Delete network.
virtual CPLErr DisconnectAll()=0
DisconnectAll method clears the network graph.
virtual int CheckNetworkExist(const char *pszFilename, CSLConstList papszOptions)=0
Check if network already exist.
static GNMGenericNetworkH ToHandle(GNMNetwork *poNetwork)
Casts a pointer to a handle.
Definition gnm.h:174
static GNMNetwork * FromHandle(GNMGenericNetworkH hNet)
Casts a handle to a pointer.
Definition gnm.h:168
virtual int GetVersion() const
GetVersion return the network version if applicable.
Definition gnm.h:133
virtual OGRFeature * GetFeatureByGlobalFID(GNMGFID nGFID)=0
GetFeatureByGlobalFID search all network layers for given feature identificator.
virtual OGRLayer * GetPath(GNMGFID nStartFID, GNMGFID nEndFID, GNMGraphAlgorithmType eAlgorithm, CSLConstList papszOptions)=0
Create path between start and end GFIDs.
virtual CPLErr Create(const char *pszFilename, CSLConstList papszOptions)=0
Create network system layers.
virtual CPLErr Open(GDALOpenInfo *poOpenInfo)=0
Open a network.
The simple class for rules.
Definition gnm.h:656
GNMRule()
Constructor.
virtual CPLString GetTargetLayerName() const
Return target layer name.
virtual bool IsAcceptAny() const
Indicator of any layer state.
virtual bool CanConnect(const CPLString &soSrcLayerName, const CPLString &soTgtLayerName, const CPLString &soConnLayerName="")
Check if connection can take place.
GNMRule(const char *pszRule)
Constructor.
GNMRule(GNMRule &&)=default
Move constructor.
const char * c_str() const
Return rule as a string.
virtual CPLString GetConnectorLayerName() const
Return connector layer name.
GNMRule(const GNMRule &)=default
Copy constructor.
virtual CPLString GetSourceLayerName() const
Return source layer name.
GNMRule & operator=(const GNMRule &)=default
Assignment operator.
GNMRule(const std::string &oRule)
Constructor.
GNMRule & operator=(GNMRule &&)=default
Move assignment operator.
virtual bool IsValid() const
This function indicate if rule string was parsed successfully.
virtual ~GNMRule()
Destructor.
virtual GNMRuleType GetType() const
This is for future use to indicate the rule type/ Now return only GRTConnection type.
Simple container for a bounding region (rectangle)
Definition ogr_core.h:44
Definition of a feature class or feature layer.
Definition ogr_feature.h:521
A simple feature, including geometry and attributes.
Definition ogr_feature.h:1041
Definition of an attribute of an OGRFeatureDefn.
Definition ogr_feature.h:72
The OGRGNMWrappedResultLayer class for search paths queries results.
Definition gnm.h:740
OGRErr InsertFeature(OGRFeature *poFeature, const CPLString &soLayerName, int nPathNo, bool bIsEdge)
Undocumented.
Definition gnmresultlayer.cpp:125
OGRErr SetNextByIndex(GIntBig nIndex) override
Move read cursor to the nIndex'th feature in the current resultset.
Definition gnmresultlayer.cpp:71
OGRErr ICreateFeature(OGRFeature *poFeature) override
Create and write a new feature within a layer.
Definition gnmresultlayer.cpp:204
OGRErr ISetFeature(OGRFeature *poFeature) override
Rewrite/replace an existing feature.
Definition gnmresultlayer.cpp:199
virtual OGRErr CreateGeomField(const OGRGeomFieldDefn *poField, int bApproxOK=TRUE) override
Create a new geometry field on a layer.
Definition gnmresultlayer.cpp:103
virtual OGRErr CreateField(const OGRFieldDefn *poField, int bApproxOK=TRUE) override
Create a new field on a layer.
Definition gnmresultlayer.cpp:96
OGRFeature * GetNextFeature() override
Fetch the next available feature from this layer.
Definition gnmresultlayer.cpp:66
const char * GetFIDColumn() const override
This method returns the name of the underlying database column being used as the FID column,...
Definition gnmresultlayer.cpp:109
int TestCapability(const char *pszCap) const override
Test if this layer supported the named capability.
Definition gnmresultlayer.cpp:91
OGRFeature * GetFeature(GIntBig nFID) override
Fetch a feature by its identifier.
Definition gnmresultlayer.cpp:76
const OGRFeatureDefn * GetLayerDefn() const override
Fetch the schema information for this layer.
Definition gnmresultlayer.cpp:81
GIntBig GetFeatureCount(int bForce=TRUE) override
Fetch the feature count in this layer.
Definition gnmresultlayer.cpp:86
const OGRSpatialReference * GetSpatialRef() const override
Fetch the spatial reference system for this layer.
Definition gnmresultlayer.cpp:119
const char * GetGeometryColumn() const override
This method returns the name of the underlying database column being used as the geometry column,...
Definition gnmresultlayer.cpp:114
void ResetReading() override
Reset feature reading to start on the first feature.
Definition gnmresultlayer.cpp:61
Definition of a geometry field of an OGRFeatureDefn.
Definition ogr_feature.h:335
Abstract base class for all geometry classes.
Definition ogr_geometry.h:357
This class represents a layer of simple features, with access methods.
Definition ogrsf_frmts.h:61
virtual OGRErr ICreateFeature(OGRFeature *poFeature)
Create and write a new feature within a layer.
Definition ogrlayer.cpp:1569
virtual OGRErr ISetFeature(OGRFeature *poFeature)
Rewrite/replace an existing feature.
Definition ogrlayer.cpp:1369
Concrete representation of a multi-vertex line.
Definition ogr_geometry.h:1739
A collection of OGRLineString.
Definition ogr_geometry.h:4076
Point class.
Definition ogr_geometry.h:1108
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition ogr_spatialref.h:152
This class represents a style table.
Definition ogr_featurestyle.h:69
CPLErr
Error category / error level.
Definition cpl_error.h:45
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition cpl_port.h:1101
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1252
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition cpl_port.h:195
void * GNMGenericNetworkH
Opaque type for a GNMGenericNetwork.
Definition gdal_fwd.h:212
OGRwkbGeometryType
List of well known binary geometry types.
Definition ogr_core.h:423
int OGRErr
Type for a OGR error.
Definition ogr_core.h:388
Classes related to registration of format support, and opening datasets.