<div dir="ltr"><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">The algorithm is using only the features that are connected manually and that are present in _gnm_graph.</blockquote><div><br></div><div>No, if you use automatic connection the _gnm_graph is also formed automatically because it internally calls ConnectFeatures().<br><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">Is there any other simple solution to solve this.<br></blockquote><div><br></div><div>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. <br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-11-11 14:48 GMT+04:00 Hema Yeedunuri <span dir="ltr"><<a href="mailto:hema.yeedunuri@amigooptima.in" target="_blank">hema.yeedunuri@amigooptima.in</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>hello Mikhail Gusev , <br><br></div>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.<br></div><div> <br></div>thanks,<br></div>hema<br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 11, 2014 at 3:59 PM, Mikhail Gusev <span dir="ltr"><<a href="mailto:gusevmihs@gmail.com" target="_blank">gusevmihs@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Hello, hema.<br></div>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.<br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>2014-11-11 11:26 GMT+04:00 yhema <span dir="ltr"><<a href="mailto:hema.yeedunuri@amigooptima.in" target="_blank">hema.yeedunuri@amigooptima.in</a>></span>:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>Hello all,<br>
<br>
I am trying to create a graph for network analysis using gdalgnm.The feature<br>
auto connect is working if we provide more than one layer.How can we connect<br>
features of a single layer so that graph is created automatically. We can<br>
connect features using connect features but automatically it is not<br>
conncting using auto connect .Here is the code.<br>
<br>
char **options = NULL;<br>
options = CSLAddNameValue(options,GNM_INIT_OPTIONPAIR_NAME,<br>
"roads_network");<br>
<br>
<br>
GNMGdalNetwork *poNet;<br>
<br>
poNet =<br>
GNMManager::GdalCreateNetwork("/home/shiva/Desktop/network/network_data",<br>
"ESRI Shapefile", "EPSG:4326", options);<br>
CSLDestroy(options);<br>
if (poNet == NULL)<br>
{<br>
printf("Failed to create network\n");<br>
exit(1);<br>
}<br>
<br>
GDALDataset *poSrcDS = (GDALDataset*)<br>
GDALOpenEx("/home/shiva/Desktop/network/data",<br>
GDAL_OF_VECTOR |<br>
GDAL_OF_READONLY, NULL, NULL, NULL );<br>
if(poSrcDS == NULL)<br>
{<br>
printf("Can not open source dataset at\n");<br>
exit(1);<br>
}<br>
<br>
OGRLayer *poSrcLayer2 = poSrcDS->GetLayerByName("roads");<br>
if (poSrcLayer2 == NULL)<br>
{<br>
printf("layer is null\n");<br>
printf("Can not process layers of source dataset\n");<br>
exit(1);<br>
}<br>
<br>
GNMErr err2 = poNet->CopyLayer(poSrcLayer2, "roads");<br>
if (err2 != GNMERR_NONE)<br>
{<br>
printf("Can not import layers from source dataset\n");<br>
exit(1);<br>
}<br>
<br>
GDALClose(poSrcDS);<br>
<br>
<br>
if (poNet->CreateRule("CLASS gnm_roads_line COSTS TIGER_ID") !=<br>
GNMERR_NONE)<br>
{<br>
printf("Can not create rule\n");<br>
}<br>
<br>
if (poNet->CreateRule("NETWORK CONNECTS gnm_roads_line WITH<br>
gnm_roads_line ") != GNMERR_NONE)<br>
{<br>
printf("Can not create rule\n");<br>
}<br>
<br>
<br>
printf("\nBuilding network topology ...\n");<br>
GDALDataset *poNetDS = poNet->GetDataset();<br>
OGRLayer **layers = new OGRLayer*[3];<br>
<br>
layers[0] = poNetDS->GetLayerByName("gnm_roads_line");<br>
layers[2] = NULL;<br>
layers[1] = NULL;<br>
<br>
<br>
if (poNet->AutoConnect(layers,0.05, NULL) != GNMERR_NONE)<br>
{<br>
printf("Building topology failed\n");<br>
exit(1);<br>
}<br>
else<br>
{<br>
printf("Topology has been built successfully\n");<br>
}<br>
<br>
delete[] layers;<br>
<br>
<br>
GNMManager::GdalCloseNetwork(poNet);<br>
<br>
<br>
<br>
<br>
thanks,<br>
hema<br>
<br>
<br>
<br></div></div><span><font color="#888888">
--<br>
View this message in context: <a href="http://osgeo-org.1560.x6.nabble.com/creating-graph-for-single-line-shape-layer-using-gdal-gnm-tp5172326.html" target="_blank">http://osgeo-org.1560.x6.nabble.com/creating-graph-for-single-line-shape-layer-using-gdal-gnm-tp5172326.html</a><br>
Sent from the GDAL - Dev mailing list archive at Nabble.com.<br>
_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</font></span></blockquote></div><br></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>