public Geometry Read(byte[] geometryData, GeometryWkbMode mode) { if (geometryData == null || geometryData.Length == 0) { throw new ArgumentNullException("geometryData"); } m_objReader.Initialize(geometryData); Geometry geometry = null; switch (mode) { case GeometryWkbMode.Standard: geometry = ReadStandard(); break; case GeometryWkbMode.Proposed: geometry = ReadProposed(); break; case GeometryWkbMode.PostGIS: geometry = ReadPostGIS(); break; case GeometryWkbMode.Custom: geometry = ReadCustom(); break; } m_objReader.Uninitialize(); // reset the buffer return(geometry); }
public byte[] Write(Geometry geometry, GeometryWkbMode wkbMode, BytesOrder order) { if (geometry == null) { throw new ArgumentNullException("geometry"); } m_objWriter.Initialize(); m_objWriter.Order = order; GeometryWkbMode mode = wkbMode; bool bResult = false; byte[] geomBytes = null; switch (mode) { case GeometryWkbMode.Standard: bResult = WriteStandard(geometry); break; case GeometryWkbMode.Proposed: bResult = WriteProposed(geometry); break; case GeometryWkbMode.PostGIS: bResult = WritePostGIS(geometry); break; case GeometryWkbMode.Custom: bResult = WriteCustom(geometry); break; } if (bResult) { geomBytes = m_objWriter.GetBuffer(); } m_objWriter.Uninitialize(); // reset the buffer return(geomBytes); }
public byte[] Write(Geometry geometry, BytesOrder order) { if (geometry == null) { throw new ArgumentNullException("geometry"); } m_objWriter.Initialize(); m_objWriter.Order = order; GeometryWkbMode mode = GeometryWkbMode.Standard; GeometryFactory factory = geometry.Factory; if (factory != null) { CoordinateType coordType = factory.CoordinateType; if (coordType == CoordinateType.Measured) { mode = GeometryWkbMode.PostGIS; } else { IGeometryProperties properties = geometry.Properties; if (properties != null && properties.Contains("SRID")) { mode = GeometryWkbMode.PostGIS; } else { int dim = factory.CoordinateDimension; if (dim == 3) { mode = GeometryWkbMode.Proposed; } } } } bool bResult = false; byte[] geomBytes = null; switch (mode) { case GeometryWkbMode.Standard: bResult = WriteStandard(geometry); break; case GeometryWkbMode.Proposed: bResult = WriteProposed(geometry); break; case GeometryWkbMode.PostGIS: bResult = WritePostGIS(geometry); break; case GeometryWkbMode.Custom: bResult = WriteCustom(geometry); break; } if (bResult) { geomBytes = m_objWriter.GetBuffer(); } m_objWriter.Uninitialize(); // reset the buffer return(geomBytes); }