public OgcSpatialFeatureclass(OgcSpatialDataset dataset, DataRow geometry_columns_row) { _dataset = dataset; if (_dataset == null || geometry_columns_row == null) { return; } try { _lastException = null; string schema = String.Empty; try { if (!String.IsNullOrEmpty(_dataset.OgcDictionary("geometry_columns.f_table_schema"))) { schema = geometry_columns_row[_dataset.OgcDictionary("geometry_columns.f_table_schema")].ToString(); } if (!String.IsNullOrEmpty(schema)) { schema += "."; } } catch { schema = ""; } _name = schema + geometry_columns_row[_dataset.OgcDictionary("geometry_columns.f_table_name")].ToString(); _shapefield = geometry_columns_row[_dataset.OgcDictionary("geometry_columns.f_geometry_column")].ToString(); _idfield = _dataset.OgcDictionary("gid"); // Read Primary Key -> PostGIS id is not always "gid"; string pKey = GetPKey(); if (!String.IsNullOrWhiteSpace(pKey) && !pKey.Equals(_idfield)) { _idfield = pKey; } _geometry_columns_type = geometry_columns_row[_dataset.OgcDictionary("geometry_columns.type")].ToString().ToUpper(); switch (_geometry_columns_type) { case "MULTIPOLYGON": case "POLYGON": case "MULTIPOLYGONM": case "POLYGONM": _geomType = geometryType.Polygon; break; case "MULTILINESTRING": case "LINESTRING": case "MULTILINESTRINGM": case "LINESTRINGM": _geomType = geometryType.Polyline; break; case "POINT": case "POINTM": case "MULTIPOINT": case "MULTIPOINTM": _geomType = geometryType.Point; break; default: _geomType = geometryType.Unknown; break; } _hasZ = (int)geometry_columns_row[_dataset.OgcDictionary("geometry_columns.coord_dimension")] == 3; try { int srid = int.Parse(geometry_columns_row[_dataset.OgcDictionary("geometry_columns.srid")].ToString()); if (srid > 0) { _sRef = gView.Framework.Geometry.SpatialReference.FromID("epsg:" + srid.ToString()); } else { _sRef = TrySelectSpatialReference(dataset, this); } } catch { } ReadSchema(); } catch (Exception ex) { _lastException = ex; string msg = ex.Message; } }
public OgcSpatialFeatureclass(OgcSpatialDataset dataset, DataRow geometry_columns_row) { _dataset = dataset; if (_dataset == null || geometry_columns_row == null) { return; } try { _lastException = null; _name = geometry_columns_row[_dataset.OgcDictionary("geometry_columns.f_table_name")].ToString(); _shapefield = geometry_columns_row[_dataset.OgcDictionary("geometry_columns.f_geometry_column")].ToString(); _idfield = _dataset.OgcDictionary("gid"); _geometry_columns_type = geometry_columns_row[_dataset.OgcDictionary("geometry_columns.type")].ToString().ToUpper(); switch (_geometry_columns_type) { case "MULTIPOLYGON": case "POLYGON": case "MULTIPOLYGONM": case "POLYGONM": _geomType = geometryType.Polygon; break; case "MULTILINESTRING": case "LINESTRING": case "MULTILINESTRINGM": case "LINESTRINGM": _geomType = geometryType.Polyline; break; case "POINT": case "POINTM": _geomType = geometryType.Point; break; default: _geomType = geometryType.Unknown; break; } _hasZ = (int)geometry_columns_row[_dataset.OgcDictionary("geometry_columns.coord_dimension")] == 3; try { int srid = int.Parse(geometry_columns_row[_dataset.OgcDictionary("geometry_columns.srid")].ToString()); if (srid > 0) { _sRef = gView.Framework.Geometry.SpatialReference.FromID("epsg:" + srid.ToString()); } else { _sRef = TrySelectSpatialReference(dataset, this); } } catch { } ReadSchema(); } catch (Exception ex) { _lastException = ex; string msg = ex.Message; } }