Ejemplo n.º 1
0
        private void btnPreview_Click(object sender, EventArgs e)
        {
            try
            {
                using (IGeometry fgeom = _geomFactory.CreateGeometry(txtGeometry.Text))
                {
                    byte[] wkb = null;
                    if (!FdoGeometryUtil.Is2D(fgeom))
                    {
                        using (IGeometry ffgeom = FdoGeometryUtil.Flatten(fgeom, _geomFactory))
                        {
                            wkb = _geomFactory.GetWkb(ffgeom);
                        }
                    }
                    else
                    {
                        wkb = _geomFactory.GetWkb(fgeom);
                    }

                    SharpMap.Geometries.Geometry sgeom = SharpMap.Geometries.Geometry.GeomFromWKB(wkb);
                    _layer.DataSource = new SharpMap.Data.Providers.GeometryProvider(sgeom);
                    SharpMap.Geometries.BoundingBox bbox = _mapCtl.Map.GetExtents();
                    bbox = bbox.Grow(2.0, 2.0);
                    _mapCtl.Map.ZoomToBox(bbox);
                    _mapCtl.Refresh();
                    btnOK.Enabled = true;
                }
            }
            catch (Exception)
            {
                MessageService.ShowError("The specified text does not constitute a valid geometry");
                btnOK.Enabled = false;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Forces the given geometry to be WKB compliant. If necessary, a <see cref="Flatten"/> call
 /// will be made on the geometry.
 /// </summary>
 /// <param name="geom"></param>
 /// <param name="fact"></param>
 /// <returns></returns>
 public static IGeometry ForceWkb(IGeometry geom, FgfGeometryFactory fact)
 {
     byte [] wkb = null;
     try
     {
         wkb = fact.GetWkb(geom);
     }
     catch
     {
         using (IGeometry wg = Flatten(geom, fact))
         {
             wkb = fact.GetWkb(geom);
         }
     }
     return(fact.CreateGeometryFromWkb(wkb));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Forces the given geometry to be WKB compliant. If necessary, a <see cref="Flatten"/> call
 /// will be made on the geometry.
 /// </summary>
 /// <param name="geom"></param>
 /// <param name="fact"></param>
 /// <returns></returns>
 public static IGeometry ForceWkb(IGeometry geom, FgfGeometryFactory fact)
 {
     byte [] wkb = null;
     try
     {
         wkb = fact.GetWkb(geom);
     }
     catch
     {
         using (IGeometry wg = Flatten(geom, fact))
         {
             wkb = fact.GetWkb(geom);
         }
     }
     return fact.CreateGeometryFromWkb(wkb);
 }
        public static GeoAPI.Geometries.IGeometry ConvertTo(OSGeo.FDO.Geometry.IGeometry geometry)
        {
            //GisSharpBlog.NetTopologySuite.IO.WKTReader wktReader = new GisSharpBlog.NetTopologySuite.IO.WKTReader();
            //GeoAPI.Geometries.IGeometry ntsGeometry = wktReader.Read( geometry.Text );
            //return ntsGeometry;

            GisSharpBlog.NetTopologySuite.IO.WKBReader wkbReader = new GisSharpBlog.NetTopologySuite.IO.WKBReader();
            FgfGeometryFactory geometryFactory = new FgfGeometryFactory();

            GeoAPI.Geometries.IGeometry ntsGeometry = wkbReader.Read(geometryFactory.GetWkb(geometry));
            return(ntsGeometry);
        }