MCPcopy Create free account
hub / github.com/OSGeo/gdal / LoadGeometry

Method LoadGeometry

swig/java/apps/GDALGrid.java:373–464  ·  view source on GitHub ↗
(String srcDS, String srcSQL, String srcLyr,
            String srcWhere)

Source from the content-addressed store, hash-verified

371 * returns a collection of read geometries.
372 */
373 static Geometry LoadGeometry(String srcDS, String srcSQL, String srcLyr,
374 String srcWhere) {
375
376 DataSource DS;
377 Layer lyr;
378 Feature feat;
379 Geometry geom = null;
380
381 DS = ogr.Open(srcDS, false);
382
383 if (DS == null) {
384
385 return null;
386 }
387
388 if (srcSQL != null) {
389
390 lyr = DS.ExecuteSQL(srcSQL, null, null);
391 } else if (srcLyr != null) {
392
393 lyr = DS.GetLayerByName(srcLyr);
394 } else {
395
396 lyr = DS.GetLayer(0);
397 }
398
399 if (lyr == null) {
400
401 System.err
402 .println("Failed to identify source layer from datasource.");
403 DS.delete();
404 return null;
405 }
406
407 if (srcWhere != null) {
408
409 lyr.SetAttributeFilter(srcWhere);
410 }
411
412 while ((feat = lyr.GetNextFeature()) != null) {
413
414 Geometry srcGeom = feat.GetGeometryRef();
415
416 if (srcGeom != null) {
417
418 int srcType = srcGeom.GetGeometryType()
419 & (~ogrConstants.wkb25DBit);
420
421 if (geom == null) {
422
423 geom = new Geometry(ogr.wkbMultiPolygon);
424 }
425
426 if (srcType == ogr.wkbPolygon) {
427
428 geom.AddGeometry(srcGeom);
429 } else if (srcType == ogr.wkbMultiPolygon) {
430

Callers 1

mainMethod · 0.95

Calls 11

deleteMethod · 0.80
AddGeometryMethod · 0.80
OpenMethod · 0.45
ExecuteSQLMethod · 0.45
GetLayerByNameMethod · 0.45
GetLayerMethod · 0.45
SetAttributeFilterMethod · 0.45
GetNextFeatureMethod · 0.45
GetGeometryRefMethod · 0.45
GetGeometryTypeMethod · 0.45
ReleaseResultSetMethod · 0.45

Tested by

no test coverage detected