Line data Source code
1 : /******************************************************************************
2 : *
3 : * Project: GDAL/OGR Geography Network support (Geographic Network Model)
4 : * Purpose: GNM network class.
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 : #include "gnm_api.h"
32 : #include "ogrsf_frmts.h"
33 :
34 16 : GNMNetwork::GNMNetwork() : GDALDataset()
35 : {
36 16 : }
37 :
38 16 : GNMNetwork::~GNMNetwork()
39 : {
40 16 : }
41 :
42 3 : const char *GNMNetwork::GetName() const
43 : {
44 3 : return m_soName;
45 : }
46 :
47 10 : const OGRSpatialReference *GNMNetwork::GetSpatialRef() const
48 : {
49 10 : return m_oSRS.IsEmpty() ? nullptr : &m_oSRS;
50 : }
51 :
52 0 : char **GNMNetwork::GetFileList()
53 : {
54 0 : return nullptr;
55 : }
56 :
57 : //--- C API --------------------------------------------------------------------
58 :
59 2 : const char *CPL_STDCALL GNMGetName(GNMNetworkH hNet)
60 : {
61 2 : VALIDATE_POINTER1(hNet, "GNMGetVersion", nullptr);
62 :
63 2 : return GNMNetwork::FromHandle(hNet)->GetName();
64 : }
65 :
66 2 : int CPL_STDCALL GNMGetVersion(GNMNetworkH hNet)
67 : {
68 2 : VALIDATE_POINTER1(hNet, "GNMGetVersion", 0);
69 :
70 2 : return GNMNetwork::FromHandle(hNet)->GetVersion();
71 : }
72 :
73 0 : CPLErr CPL_STDCALL GNMDisconnectAll(GNMNetworkH hNet)
74 : {
75 0 : VALIDATE_POINTER1(hNet, "GNMDisconnectAll", CE_Failure);
76 :
77 0 : return GNMNetwork::FromHandle(hNet)->DisconnectAll();
78 : }
79 :
80 0 : OGRFeatureH CPL_STDCALL GNMGetFeatureByGlobalFID(GNMNetworkH hNet,
81 : GNMGFID nGFID)
82 : {
83 0 : VALIDATE_POINTER1(hNet, "GNMGetFeatureByGlobalFID", nullptr);
84 :
85 0 : return OGRFeature::ToHandle(
86 0 : GNMNetwork::FromHandle(hNet)->GetFeatureByGlobalFID(nGFID));
87 : }
88 :
89 3 : OGRLayerH CPL_STDCALL GNMGetPath(GNMNetworkH hNet, GNMGFID nStartFID,
90 : GNMGFID nEndFID,
91 : GNMGraphAlgorithmType eAlgorithm,
92 : char **papszOptions)
93 : {
94 3 : VALIDATE_POINTER1(hNet, "GNMGetPath", nullptr);
95 :
96 6 : return OGRLayer::ToHandle(GNMNetwork::FromHandle(hNet)->GetPath(
97 6 : nStartFID, nEndFID, eAlgorithm, papszOptions));
98 : }
99 :
100 5 : GNMNetworkH CPL_STDCALL GNMCastToNetwork(GDALMajorObjectH hBase)
101 : {
102 10 : return GNMNetwork::ToHandle(
103 15 : dynamic_cast<GNMNetwork *>(GDALMajorObject::FromHandle(hBase)));
104 : }
105 :
106 1 : GNMGenericNetworkH CPL_STDCALL GNMCastToGenericNetwork(GDALMajorObjectH hBase)
107 : {
108 2 : return GNMGenericNetwork::ToHandle(
109 3 : dynamic_cast<GNMGenericNetwork *>(GDALMajorObject::FromHandle(hBase)));
110 : }
|