예제 #1
0
        public void QueryShape(IGeometry pGeometry)
        {
            if (pGeometry == null)
            {
                return;
            }

            try
            {
                OSGeo.OGR.Geometry ogrGeometry = m_currentOGRFeature.GetGeometryRef();

                //export geometry from OGR to WKB
                int    wkbSize   = ogrGeometry.WkbSize();
                byte[] wkbBuffer = new byte[wkbSize];
                ogrGeometry.ExportToWkb(wkbBuffer);

                //import geometry from WKB to ESRI Shape
                IWkb pWKB = pGeometry as IWkb;
                pWKB.ImportFromWkb(wkbSize, ref wkbBuffer[0]);

                pGeometry.SpatialReference = m_pDataset.SpatialReference;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(" Error: " + ex.Message);
                pGeometry.SetEmpty();
            }
        }
예제 #2
0
        public void QueryShape(IGeometry pGeometry)
        {
            if (pGeometry == null)
            {
                return;
            }

            try
            {
                OSGeo.OGR.Geometry ogrGeometry = m_currentOGRFeature.GetGeometryRef();

                // Flatten the geometry and ommit Z value until we add manual
                // Z-value zupport
                // See:
                // https://github.com/RBURHUM/arcgis-ogr/issues/11
                //
                //
                ogrGeometry.FlattenTo2D();

                //export geometry from OGR to WKB
                int    wkbSize   = ogrGeometry.WkbSize();
                byte[] wkbBuffer = new byte[wkbSize];
                ogrGeometry.ExportToWkb(wkbBuffer);

                //import geometry from WKB to ESRI Shape
                IWkb pWKB = pGeometry as IWkb;
                pWKB.ImportFromWkb(wkbSize, ref wkbBuffer[0]);

                pGeometry.SpatialReference = m_pDataset.SpatialReference;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(" Error: " + ex.Message);
                pGeometry.SetEmpty();
            }
        }