/// <summary> /// Initializes a new instance of the <see cref="Geometry"/> class. /// </summary> /// <param name="type">The geometry type.</param> /// <param name="zValue">The z value.</param> public Geometry(GeometryType type, ZValueType zValue = ZValueType.None) { _shape = new Shape(); var shpType = GeometryHelper.GeometryType2ShpType(type, zValue); _shape.Create(shpType); }
/// <summary> /// Creates featureset with the same projection and set of fields, but differnt geometry type. /// </summary> public IFeatureSet Clone(GeometryType newType, ZValueType zValue = ZValueType.None) { var sf = new Shapefile(); var shapeType = GeometryHelper.GeometryType2ShpType(newType, zValue); sf.CreateNew(string.Empty, shapeType); sf.GeoProjection.CopyFrom(_shapefile.GeoProjection); var fs = new FeatureSet(sf); foreach (var fld in Fields) { fs.Fields.Add(fld.Clone()); } return(fs); }
/// <summary> /// Creates a new in-memory FeatureSet not bound to any datasource. /// </summary> public FeatureSet(GeometryType geomType, ZValueType zValue = ZValueType.None, bool addShapeIdField = true) { if (geomType == GeometryType.None) { throw new ArgumentException("Invalid geometry type."); } var shpType = GeometryHelper.GeometryType2ShpType(geomType, zValue); _shapefile = new Shapefile(); if (!addShapeIdField) { _shapefile.CreateNew("", shpType); } else { _shapefile.CreateNewWithShapeID("", shpType); } }
public bool AddDatabaseLayer( string connection, string layerName, GeometryType multiGeometryType = GeometryType.None, ZValueType zValue = ZValueType.None) { var layer = new VectorLayer(); if (layer.Open(connection, layerName)) { if (multiGeometryType != GeometryType.None) { layer.SetActiveGeometryType(multiGeometryType, zValue); } return(AddDatasource(layer)); } return(false); }
/// <summary> /// Creates a new disk-based shapefile and open it as new feature set. /// </summary> /// <returns>Feature set for newly created shapefile.</returns> public static IFeatureSet CreateShapefile(string filename, GeometryType geomType, ZValueType zValue = ZValueType.None) { if (geomType == GeometryType.None) { throw new ArgumentException("Invalid geometry type."); } var shpType = GeometryHelper.GeometryType2ShpType(geomType, zValue); var sf = new Shapefile(); if (!sf.CreateNew(filename, shpType)) { throw new ApplicationException("Failed to create shapefile: " + sf.ErrorMessage()); } var fs = new FeatureSet(sf); return(fs); }
/// <summary> /// Clones points and parts but allows to set different geometry type. /// The method doesn't check if the result geometry is valid. /// </summary> public IGeometry Clone(GeometryType type, ZValueType zValue = ZValueType.None) { var shapeType = GeometryHelper.GeometryType2ShpType(type, zValue); var shp = new Shape(); shp.Create(shapeType); for (int i = 0; i < _shape.NumParts; i++) { int pointIndex = _shape.Part[i]; shp.InsertPart(i, ref pointIndex); } var g = new Geometry(shp); foreach (var pnt in Points) { g.Points.Add(pnt.Clone()); } return(g); }
public void SetActiveGeometryType(GeometryType type, ZValueType zValue) { _layer.ActiveShapeType = GeometryHelper.GeometryType2ShpType(type, zValue); }
private void OnFormClosing(object sender, FormClosingEventArgs e) { _lastGeometryType = GeometryType; _lastZValue = ZValueType; _lastMemoryLayer = chkMemoryLayer.Checked; }
public LayerIdentity(string connection, string query, GeometryType geometryType, ZValueType zValue = ZValueType.None) { Connection = connection; Query = query; IdentityType = LayerIdentityType.OgrDatasource; GeometryType = geometryType; }
public static ShpfileType GeometryType2ShpType(GeometryType type, ZValueType zValue = ZValueType.None) { switch (type) { case GeometryType.None: return(ShpfileType.SHP_NULLSHAPE); case GeometryType.Point: if (zValue == ZValueType.None) { return(ShpfileType.SHP_POINT); } if (zValue == ZValueType.M) { return(ShpfileType.SHP_POINTM); } if (zValue == ZValueType.Z) { return(ShpfileType.SHP_POINTZ); } break; case GeometryType.Polyline: if (zValue == ZValueType.None) { return(ShpfileType.SHP_POLYLINE); } if (zValue == ZValueType.M) { return(ShpfileType.SHP_POLYLINEM); } if (zValue == ZValueType.Z) { return(ShpfileType.SHP_POLYLINEZ); } break; case GeometryType.Polygon: if (zValue == ZValueType.None) { return(ShpfileType.SHP_POLYGON); } if (zValue == ZValueType.M) { return(ShpfileType.SHP_POLYGONM); } if (zValue == ZValueType.Z) { return(ShpfileType.SHP_POLYGONZ); } break; case GeometryType.MultiPoint: if (zValue == ZValueType.None) { return(ShpfileType.SHP_MULTIPOINT); } if (zValue == ZValueType.M) { return(ShpfileType.SHP_MULTIPOINTM); } if (zValue == ZValueType.Z) { return(ShpfileType.SHP_MULTIPOINTZ); } break; } return(ShpfileType.SHP_NULLSHAPE); }
public ComplexGeometryType(GeometryType type, ZValueType zValue = Enums.ZValueType.None) { _shpType = GeometryHelper.GeometryType2ShpType(GeometryType, ZValueType); }