creating graph for single line shape layer using gdal gnm

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

creating graph for single line shape layer using gdal gnm

yhema
Hello all,

I am trying to create a graph for network analysis using gdalgnm.The feature auto connect is working if we provide more than one layer.How can we connect features of a single layer so that graph is created automatically. We can connect features using connect features but automatically it is not conncting using auto connect .Here is the code.

 char **options = NULL;
    options = CSLAddNameValue(options,GNM_INIT_OPTIONPAIR_NAME, "roads_network");
   
   
    GNMGdalNetwork *poNet;
   
    poNet = GNMManager::GdalCreateNetwork("/home/shiva/Desktop/network/network_data", "ESRI Shapefile", "EPSG:4326", options);
    CSLDestroy(options);
    if (poNet == NULL)
    {
        printf("Failed to create network\n");
        exit(1);
    }
   
    GDALDataset *poSrcDS = (GDALDataset*) GDALOpenEx("/home/shiva/Desktop/network/data",
                                                     GDAL_OF_VECTOR | GDAL_OF_READONLY, NULL, NULL, NULL );
    if(poSrcDS == NULL)
    {
        printf("Can not open source dataset at\n");
        exit(1);
    }
   
    OGRLayer *poSrcLayer2 = poSrcDS->GetLayerByName("roads");
    if (poSrcLayer2 == NULL)
    {
        printf("layer is null\n");
        printf("Can not process layers of source dataset\n");
        exit(1);
    }
   
    GNMErr err2 = poNet->CopyLayer(poSrcLayer2, "roads");
    if (err2 != GNMERR_NONE)
    {
        printf("Can not import layers from source dataset\n");
        exit(1);
    }
   
    GDALClose(poSrcDS);
   
   
    if (poNet->CreateRule("CLASS gnm_roads_line COSTS TIGER_ID") != GNMERR_NONE)
    {
        printf("Can not create rule\n");
    }
   
    if (poNet->CreateRule("NETWORK CONNECTS gnm_roads_line WITH gnm_roads_line  ") != GNMERR_NONE)
    {
        printf("Can not create rule\n");
    }
   
   
    printf("\nBuilding network topology ...\n");
    GDALDataset *poNetDS = poNet->GetDataset();
    OGRLayer **layers = new OGRLayer*[3];
   
    layers[0] = poNetDS->GetLayerByName("gnm_roads_line");
    layers[2] = NULL;
    layers[1] = NULL;
   
   
    if (poNet->AutoConnect(layers,0.05, NULL) != GNMERR_NONE)
    {
        printf("Building topology failed\n");
        exit(1);
    }
    else
    {
        printf("Topology has been built successfully\n");
    }
   
    delete[] layers;
   
   
        GNMManager::GdalCloseNetwork(poNet);




thanks,
hema
Reply | Threaded
Open this post in threaded view
|

Re: creating graph for single line shape layer using gdal gnm

Михаил Гусев
Hello, hema.
The current default implementation of GNMNetwork::AutoConnect() can work only if the passing array of layers contains at least one point and one line layer (i.e. GetGeomType() for the layers equals wkbPoint and wkbLineString accordingly). For each line feature the algorithm takes the start and end snapping area formed around the start and end point of the line and searches the points from point layers which are situated inside these two areas. So there is no way for now to connect features of only one line layer automatically. You can use ConnectFeatures() to connect manually, but you will need the features (with any geometry!) to be the source and the target for the connection, while the gnm_roads_line feature will be the connector.

2014-11-11 11:26 GMT+04:00 yhema <[hidden email]>:
Hello all,

I am trying to create a graph for network analysis using gdalgnm.The feature
auto connect is working if we provide more than one layer.How can we connect
features of a single layer so that graph is created automatically. We can
connect features using connect features but automatically it is not
conncting using auto connect .Here is the code.

 char **options = NULL;
    options = CSLAddNameValue(options,GNM_INIT_OPTIONPAIR_NAME,
"roads_network");


    GNMGdalNetwork *poNet;

    poNet =
GNMManager::GdalCreateNetwork("/home/shiva/Desktop/network/network_data",
"ESRI Shapefile", "EPSG:4326", options);
    CSLDestroy(options);
    if (poNet == NULL)
    {
        printf("Failed to create network\n");
        exit(1);
    }

    GDALDataset *poSrcDS = (GDALDataset*)
GDALOpenEx("/home/shiva/Desktop/network/data",
                                                     GDAL_OF_VECTOR |
GDAL_OF_READONLY, NULL, NULL, NULL );
    if(poSrcDS == NULL)
    {
        printf("Can not open source dataset at\n");
        exit(1);
    }

    OGRLayer *poSrcLayer2 = poSrcDS->GetLayerByName("roads");
    if (poSrcLayer2 == NULL)
    {
        printf("layer is null\n");
        printf("Can not process layers of source dataset\n");
        exit(1);
    }

    GNMErr err2 = poNet->CopyLayer(poSrcLayer2, "roads");
    if (err2 != GNMERR_NONE)
    {
        printf("Can not import layers from source dataset\n");
        exit(1);
    }

    GDALClose(poSrcDS);


    if (poNet->CreateRule("CLASS gnm_roads_line COSTS TIGER_ID") !=
GNMERR_NONE)
    {
        printf("Can not create rule\n");
    }

    if (poNet->CreateRule("NETWORK CONNECTS gnm_roads_line WITH
gnm_roads_line  ") != GNMERR_NONE)
    {
        printf("Can not create rule\n");
    }


    printf("\nBuilding network topology ...\n");
    GDALDataset *poNetDS = poNet->GetDataset();
    OGRLayer **layers = new OGRLayer*[3];

    layers[0] = poNetDS->GetLayerByName("gnm_roads_line");
    layers[2] = NULL;
    layers[1] = NULL;


    if (poNet->AutoConnect(layers,0.05, NULL) != GNMERR_NONE)
    {
        printf("Building topology failed\n");
        exit(1);
    }
    else
    {
        printf("Topology has been built successfully\n");
    }

    delete[] layers;


        GNMManager::GdalCloseNetwork(poNet);




thanks,
hema



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/creating-graph-for-single-line-shape-layer-using-gdal-gnm-tp5172326.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.
_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev


_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: creating graph for single line shape layer using gdal gnm

yhema
hello Mikhail Gusev ,

Thank u for the reply .I want to find  the shortest distance between features .But the road layer I am using is having 10055 features. without creating graph it is not possible to find shortest distance.And to my understanding I think it is difficult to manually connect features to create graph. The algorithm is using only the features that are connected manually and that are present in _gnm_graph.dbf file.Is there any other simple solution to solve this.
 
thanks,
hema

On Tue, Nov 11, 2014 at 3:59 PM, Mikhail Gusev <[hidden email]> wrote:
Hello, hema.
The current default implementation of GNMNetwork::AutoConnect() can work only if the passing array of layers contains at least one point and one line layer (i.e. GetGeomType() for the layers equals wkbPoint and wkbLineString accordingly). For each line feature the algorithm takes the start and end snapping area formed around the start and end point of the line and searches the points from point layers which are situated inside these two areas. So there is no way for now to connect features of only one line layer automatically. You can use ConnectFeatures() to connect manually, but you will need the features (with any geometry!) to be the source and the target for the connection, while the gnm_roads_line feature will be the connector.

2014-11-11 11:26 GMT+04:00 yhema <[hidden email]>:
Hello all,

I am trying to create a graph for network analysis using gdalgnm.The feature
auto connect is working if we provide more than one layer.How can we connect
features of a single layer so that graph is created automatically. We can
connect features using connect features but automatically it is not
conncting using auto connect .Here is the code.

 char **options = NULL;
    options = CSLAddNameValue(options,GNM_INIT_OPTIONPAIR_NAME,
"roads_network");


    GNMGdalNetwork *poNet;

    poNet =
GNMManager::GdalCreateNetwork("/home/shiva/Desktop/network/network_data",
"ESRI Shapefile", "EPSG:4326", options);
    CSLDestroy(options);
    if (poNet == NULL)
    {
        printf("Failed to create network\n");
        exit(1);
    }

    GDALDataset *poSrcDS = (GDALDataset*)
GDALOpenEx("/home/shiva/Desktop/network/data",
                                                     GDAL_OF_VECTOR |
GDAL_OF_READONLY, NULL, NULL, NULL );
    if(poSrcDS == NULL)
    {
        printf("Can not open source dataset at\n");
        exit(1);
    }

    OGRLayer *poSrcLayer2 = poSrcDS->GetLayerByName("roads");
    if (poSrcLayer2 == NULL)
    {
        printf("layer is null\n");
        printf("Can not process layers of source dataset\n");
        exit(1);
    }

    GNMErr err2 = poNet->CopyLayer(poSrcLayer2, "roads");
    if (err2 != GNMERR_NONE)
    {
        printf("Can not import layers from source dataset\n");
        exit(1);
    }

    GDALClose(poSrcDS);


    if (poNet->CreateRule("CLASS gnm_roads_line COSTS TIGER_ID") !=
GNMERR_NONE)
    {
        printf("Can not create rule\n");
    }

    if (poNet->CreateRule("NETWORK CONNECTS gnm_roads_line WITH
gnm_roads_line  ") != GNMERR_NONE)
    {
        printf("Can not create rule\n");
    }


    printf("\nBuilding network topology ...\n");
    GDALDataset *poNetDS = poNet->GetDataset();
    OGRLayer **layers = new OGRLayer*[3];

    layers[0] = poNetDS->GetLayerByName("gnm_roads_line");
    layers[2] = NULL;
    layers[1] = NULL;


    if (poNet->AutoConnect(layers,0.05, NULL) != GNMERR_NONE)
    {
        printf("Building topology failed\n");
        exit(1);
    }
    else
    {
        printf("Topology has been built successfully\n");
    }

    delete[] layers;


        GNMManager::GdalCloseNetwork(poNet);




thanks,
hema



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/creating-graph-for-single-line-shape-layer-using-gdal-gnm-tp5172326.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.
_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev



_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: creating graph for single line shape layer using gdal gnm

Михаил Гусев
The algorithm is using only the features that are connected manually and that are present in _gnm_graph.

No, if you use automatic connection the  _gnm_graph is also formed automatically because it internally calls ConnectFeatures().

Is there any other simple solution to solve this.

It is no other solution for now to solve this. I think in the nearest future the new algorithm of automatic connection can be written (which regards only line layers and determines the start and end point of the lines automatically), I'm working on this now.

2014-11-11 14:48 GMT+04:00 Hema Yeedunuri <[hidden email]>:
hello Mikhail Gusev ,

Thank u for the reply .I want to find  the shortest distance between features .But the road layer I am using is having 10055 features. without creating graph it is not possible to find shortest distance.And to my understanding I think it is difficult to manually connect features to create graph. The algorithm is using only the features that are connected manually and that are present in _gnm_graph.dbf file.Is there any other simple solution to solve this.
 
thanks,
hema

On Tue, Nov 11, 2014 at 3:59 PM, Mikhail Gusev <[hidden email]> wrote:
Hello, hema.
The current default implementation of GNMNetwork::AutoConnect() can work only if the passing array of layers contains at least one point and one line layer (i.e. GetGeomType() for the layers equals wkbPoint and wkbLineString accordingly). For each line feature the algorithm takes the start and end snapping area formed around the start and end point of the line and searches the points from point layers which are situated inside these two areas. So there is no way for now to connect features of only one line layer automatically. You can use ConnectFeatures() to connect manually, but you will need the features (with any geometry!) to be the source and the target for the connection, while the gnm_roads_line feature will be the connector.

2014-11-11 11:26 GMT+04:00 yhema <[hidden email]>:
Hello all,

I am trying to create a graph for network analysis using gdalgnm.The feature
auto connect is working if we provide more than one layer.How can we connect
features of a single layer so that graph is created automatically. We can
connect features using connect features but automatically it is not
conncting using auto connect .Here is the code.

 char **options = NULL;
    options = CSLAddNameValue(options,GNM_INIT_OPTIONPAIR_NAME,
"roads_network");


    GNMGdalNetwork *poNet;

    poNet =
GNMManager::GdalCreateNetwork("/home/shiva/Desktop/network/network_data",
"ESRI Shapefile", "EPSG:4326", options);
    CSLDestroy(options);
    if (poNet == NULL)
    {
        printf("Failed to create network\n");
        exit(1);
    }

    GDALDataset *poSrcDS = (GDALDataset*)
GDALOpenEx("/home/shiva/Desktop/network/data",
                                                     GDAL_OF_VECTOR |
GDAL_OF_READONLY, NULL, NULL, NULL );
    if(poSrcDS == NULL)
    {
        printf("Can not open source dataset at\n");
        exit(1);
    }

    OGRLayer *poSrcLayer2 = poSrcDS->GetLayerByName("roads");
    if (poSrcLayer2 == NULL)
    {
        printf("layer is null\n");
        printf("Can not process layers of source dataset\n");
        exit(1);
    }

    GNMErr err2 = poNet->CopyLayer(poSrcLayer2, "roads");
    if (err2 != GNMERR_NONE)
    {
        printf("Can not import layers from source dataset\n");
        exit(1);
    }

    GDALClose(poSrcDS);


    if (poNet->CreateRule("CLASS gnm_roads_line COSTS TIGER_ID") !=
GNMERR_NONE)
    {
        printf("Can not create rule\n");
    }

    if (poNet->CreateRule("NETWORK CONNECTS gnm_roads_line WITH
gnm_roads_line  ") != GNMERR_NONE)
    {
        printf("Can not create rule\n");
    }


    printf("\nBuilding network topology ...\n");
    GDALDataset *poNetDS = poNet->GetDataset();
    OGRLayer **layers = new OGRLayer*[3];

    layers[0] = poNetDS->GetLayerByName("gnm_roads_line");
    layers[2] = NULL;
    layers[1] = NULL;


    if (poNet->AutoConnect(layers,0.05, NULL) != GNMERR_NONE)
    {
        printf("Building topology failed\n");
        exit(1);
    }
    else
    {
        printf("Topology has been built successfully\n");
    }

    delete[] layers;


        GNMManager::GdalCloseNetwork(poNet);




thanks,
hema



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/creating-graph-for-single-line-shape-layer-using-gdal-gnm-tp5172326.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.
_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev




_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: creating graph for single line shape layer using gdal gnm

yhema
hello Mikhail Gusev ,

Is it correct to do this way?First I will save point layer using start and end points of line  layer.Again then connect the two layers using autoconnect method . So that I can find shortest path between features of the line layer.
 
thanks,
hema

On Wed, Nov 12, 2014 at 3:03 PM, Михаил Гусев [via OSGeo.org] <[hidden email]> wrote:
The algorithm is using only the features that are connected manually and that are present in _gnm_graph.

No, if you use automatic connection the  _gnm_graph is also formed automatically because it internally calls ConnectFeatures().

Is there any other simple solution to solve this.

It is no other solution for now to solve this. I think in the nearest future the new algorithm of automatic connection can be written (which regards only line layers and determines the start and end point of the lines automatically), I'm working on this now.

2014-11-11 14:48 GMT+04:00 Hema Yeedunuri <[hidden email]>:
hello Mikhail Gusev ,

Thank u for the reply .I want to find  the shortest distance between features .But the road layer I am using is having 10055 features. without creating graph it is not possible to find shortest distance.And to my understanding I think it is difficult to manually connect features to create graph. The algorithm is using only the features that are connected manually and that are present in _gnm_graph.dbf file.Is there any other simple solution to solve this.
 
thanks,
hema

On Tue, Nov 11, 2014 at 3:59 PM, Mikhail Gusev <[hidden email]> wrote:
Hello, hema.
The current default implementation of GNMNetwork::AutoConnect() can work only if the passing array of layers contains at least one point and one line layer (i.e. GetGeomType() for the layers equals wkbPoint and wkbLineString accordingly). For each line feature the algorithm takes the start and end snapping area formed around the start and end point of the line and searches the points from point layers which are situated inside these two areas. So there is no way for now to connect features of only one line layer automatically. You can use ConnectFeatures() to connect manually, but you will need the features (with any geometry!) to be the source and the target for the connection, while the gnm_roads_line feature will be the connector.

2014-11-11 11:26 GMT+04:00 yhema <[hidden email]>:
Hello all,

I am trying to create a graph for network analysis using gdalgnm.The feature
auto connect is working if we provide more than one layer.How can we connect
features of a single layer so that graph is created automatically. We can
connect features using connect features but automatically it is not
conncting using auto connect .Here is the code.

 char **options = NULL;
    options = CSLAddNameValue(options,GNM_INIT_OPTIONPAIR_NAME,
"roads_network");


    GNMGdalNetwork *poNet;

    poNet =
GNMManager::GdalCreateNetwork("/home/shiva/Desktop/network/network_data",
"ESRI Shapefile", "EPSG:4326", options);
    CSLDestroy(options);
    if (poNet == NULL)
    {
        printf("Failed to create network\n");
        exit(1);
    }

    GDALDataset *poSrcDS = (GDALDataset*)
GDALOpenEx("/home/shiva/Desktop/network/data",
                                                     GDAL_OF_VECTOR |
GDAL_OF_READONLY, NULL, NULL, NULL );
    if(poSrcDS == NULL)
    {
        printf("Can not open source dataset at\n");
        exit(1);
    }

    OGRLayer *poSrcLayer2 = poSrcDS->GetLayerByName("roads");
    if (poSrcLayer2 == NULL)
    {
        printf("layer is null\n");
        printf("Can not process layers of source dataset\n");
        exit(1);
    }

    GNMErr err2 = poNet->CopyLayer(poSrcLayer2, "roads");
    if (err2 != GNMERR_NONE)
    {
        printf("Can not import layers from source dataset\n");
        exit(1);
    }

    GDALClose(poSrcDS);


    if (poNet->CreateRule("CLASS gnm_roads_line COSTS TIGER_ID") !=
GNMERR_NONE)
    {
        printf("Can not create rule\n");
    }

    if (poNet->CreateRule("NETWORK CONNECTS gnm_roads_line WITH
gnm_roads_line  ") != GNMERR_NONE)
    {
        printf("Can not create rule\n");
    }


    printf("\nBuilding network topology ...\n");
    GDALDataset *poNetDS = poNet->GetDataset();
    OGRLayer **layers = new OGRLayer*[3];

    layers[0] = poNetDS->GetLayerByName("gnm_roads_line");
    layers[2] = NULL;
    layers[1] = NULL;


    if (poNet->AutoConnect(layers,0.05, NULL) != GNMERR_NONE)
    {
        printf("Building topology failed\n");
        exit(1);
    }
    else
    {
        printf("Topology has been built successfully\n");
    }

    delete[] layers;


        GNMManager::GdalCloseNetwork(poNet);




thanks,
hema



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/creating-graph-for-single-line-shape-layer-using-gdal-gnm-tp5172326.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.
_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev




_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev


If you reply to this email, your message will be added to the discussion below:
http://osgeo-org.1560.x6.nabble.com/creating-graph-for-single-line-shape-layer-using-gdal-gnm-tp5172326p5172509.html
To unsubscribe from creating graph for single line shape layer using gdal gnm, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: creating graph for single line shape layer using gdal gnm

Михаил Гусев
Is it correct to do this way?First I will save point layer using start and end points of line  layer.Again then connect the two layers using autoconnect method . So that I can find shortest path between features of the line layer.

hema,
yes it's correct, but note, that there must be only one point in a junction of two line ends in order the connection will be made correct.

2014-11-12 14:28 GMT+04:00 yhema <[hidden email]>:
hello Mikhail Gusev ,

Is it correct to do this way?First I will save point layer using start and end points of line  layer.Again then connect the two layers using autoconnect method . So that I can find shortest path between features of the line layer.
 
thanks,
hema

On Wed, Nov 12, 2014 at 3:03 PM, Михаил Гусев [via OSGeo.org] <[hidden email]> wrote:
The algorithm is using only the features that are connected manually and that are present in _gnm_graph.

No, if you use automatic connection the  _gnm_graph is also formed automatically because it internally calls ConnectFeatures().

Is there any other simple solution to solve this.

It is no other solution for now to solve this. I think in the nearest future the new algorithm of automatic connection can be written (which regards only line layers and determines the start and end point of the lines automatically), I'm working on this now.

2014-11-11 14:48 GMT+04:00 Hema Yeedunuri <[hidden email]>:
hello Mikhail Gusev ,

Thank u for the reply .I want to find  the shortest distance between features .But the road layer I am using is having 10055 features. without creating graph it is not possible to find shortest distance.And to my understanding I think it is difficult to manually connect features to create graph. The algorithm is using only the features that are connected manually and that are present in _gnm_graph.dbf file.Is there any other simple solution to solve this.
 
thanks,
hema

On Tue, Nov 11, 2014 at 3:59 PM, Mikhail Gusev <[hidden email]> wrote:
Hello, hema.
The current default implementation of GNMNetwork::AutoConnect() can work only if the passing array of layers contains at least one point and one line layer (i.e. GetGeomType() for the layers equals wkbPoint and wkbLineString accordingly). For each line feature the algorithm takes the start and end snapping area formed around the start and end point of the line and searches the points from point layers which are situated inside these two areas. So there is no way for now to connect features of only one line layer automatically. You can use ConnectFeatures() to connect manually, but you will need the features (with any geometry!) to be the source and the target for the connection, while the gnm_roads_line feature will be the connector.

2014-11-11 11:26 GMT+04:00 yhema <[hidden email]>:
Hello all,

I am trying to create a graph for network analysis using gdalgnm.The feature
auto connect is working if we provide more than one layer.How can we connect
features of a single layer so that graph is created automatically. We can
connect features using connect features but automatically it is not
conncting using auto connect .Here is the code.

 char **options = NULL;
    options = CSLAddNameValue(options,GNM_INIT_OPTIONPAIR_NAME,
"roads_network");


    GNMGdalNetwork *poNet;

    poNet =
GNMManager::GdalCreateNetwork("/home/shiva/Desktop/network/network_data",
"ESRI Shapefile", "EPSG:4326", options);
    CSLDestroy(options);
    if (poNet == NULL)
    {
        printf("Failed to create network\n");
        exit(1);
    }

    GDALDataset *poSrcDS = (GDALDataset*)
GDALOpenEx("/home/shiva/Desktop/network/data",
                                                     GDAL_OF_VECTOR |
GDAL_OF_READONLY, NULL, NULL, NULL );
    if(poSrcDS == NULL)
    {
        printf("Can not open source dataset at\n");
        exit(1);
    }

    OGRLayer *poSrcLayer2 = poSrcDS->GetLayerByName("roads");
    if (poSrcLayer2 == NULL)
    {
        printf("layer is null\n");
        printf("Can not process layers of source dataset\n");
        exit(1);
    }

    GNMErr err2 = poNet->CopyLayer(poSrcLayer2, "roads");
    if (err2 != GNMERR_NONE)
    {
        printf("Can not import layers from source dataset\n");
        exit(1);
    }

    GDALClose(poSrcDS);


    if (poNet->CreateRule("CLASS gnm_roads_line COSTS TIGER_ID") !=
GNMERR_NONE)
    {
        printf("Can not create rule\n");
    }

    if (poNet->CreateRule("NETWORK CONNECTS gnm_roads_line WITH
gnm_roads_line  ") != GNMERR_NONE)
    {
        printf("Can not create rule\n");
    }


    printf("\nBuilding network topology ...\n");
    GDALDataset *poNetDS = poNet->GetDataset();
    OGRLayer **layers = new OGRLayer*[3];

    layers[0] = poNetDS->GetLayerByName("gnm_roads_line");
    layers[2] = NULL;
    layers[1] = NULL;


    if (poNet->AutoConnect(layers,0.05, NULL) != GNMERR_NONE)
    {
        printf("Building topology failed\n");
        exit(1);
    }
    else
    {
        printf("Topology has been built successfully\n");
    }

    delete[] layers;


        GNMManager::GdalCloseNetwork(poNet);




thanks,
hema



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/creating-graph-for-single-line-shape-layer-using-gdal-gnm-tp5172326.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.
_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev




_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev


If you reply to this email, your message will be added to the discussion below:
http://osgeo-org.1560.x6.nabble.com/creating-graph-for-single-line-shape-layer-using-gdal-gnm-tp5172326p5172509.html
To unsubscribe from creating graph for single line shape layer using gdal gnm, click here.
NAML



View this message in context: Re: creating graph for single line shape layer using gdal gnm

Sent from the GDAL - Dev mailing list archive at Nabble.com.

_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev


_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: creating graph for single line shape layer using gdal gnm

Rahkonen Jukka (Tike)
Mikhail Gusev <gusevmihs <at> gmail.com> writes:


>
> Is it correct to do this way?First I will save point layer using
> start and end points of line  layer.Again then connect the two layers
> using autoconnect method . So that I can find shortest path between
> features of the line layer.
>
> hema,
> yes it's correct, but note, that there must be only one point in a
junction of two line ends in order the connection will be made correct.


Hi,

You can create such point shapefile from a line shapefile with ogr2ogr by
utilizing Spatialite:

ogr2ogr -f "ESRI Shapefile" nodes.shp lines.shp -dialect sqlite -sql "SELECT
ST_StartPoint(geometry) AS node_geometry FROM lines UNION SELECT
ST_EndPoint(geometry) AS node_geometry FROM lines"

-Jukka Rahkonen-

_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev