Ejemplo n.º 1
0
        public void SetData(Geometry geometry)
        {
            wkbGeometryType geomType = geometry.GetGeometryType();

            if (geomType != wkbGeometryType.wkbPolygon && geomType != wkbGeometryType.wkbPolygon25D)
            {
                Console.WriteLine("internal error: geometry is neither polygon");
                return;
            }

            int geomCount = geometry.GetGeometryCount();

            for (int i = 0; i < geomCount; i++)
            {
                Geometry geom = geometry.GetGeometryRef(i);

                if (geom.GetGeometryType() == wkbGeometryType.wkbLineString || geom.GetGeometryType() == wkbGeometryType.wkbLineString25D)
                {
                    GeoLineString lineString = new GeoLineString();
                    lineString.SetData(geom);

                    _lineStringArray.Add(lineString);
                }
                else
                {
                    Console.WriteLine("internal error: geom is not linestring!");
                }
            }
        }
Ejemplo n.º 2
0
        public static GeoPoint ReadGeoCenterPointByRegionKey(string iso3166_2RegionCode)
        {
            iso3166_2RegionCode = ConvertRegionCodeToIso3166_2RegionCode(iso3166_2RegionCode);

            String sql = "SELECT geom FROM level1 WHERE HASC_1 = " + "'" + iso3166_2RegionCode + "'";

            Layer resultLayer = _dataSource.ExecuteSQL(sql, null, "");

            if (resultLayer == null)
            {
                return(null);
            }

            if (resultLayer.GetFeatureCount(0) == 0)
            {
                return(null);
            }

            Feature  feature  = resultLayer.GetNextFeature();
            Geometry geometry = feature.GetGeometryRef();

            geometry = geometry.Centroid();

            wkbGeometryType geomType = geometry.GetGeometryType();

            string[] options      = new string[1];
            string   geometryJson = geometry.ExportToJson(options);

            GeoPoint point = new GeoPoint();

            point.SetData(geometry);
            point.SetGeoJson(geometryJson);

            return(point);
        }
Ejemplo n.º 3
0
        private void layerList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            curLayer = layerList.SelectedItem as GisSmartTools.Support.Layer;
            if (curLayer.style != null)
            {
                rulelist = curLayer.style.rulelist;
            }
            else
            {
                GisSmartTools.Support.Style newsimplestyle = GisSmartTools.Support.Style.createSimpleStyle(curLayer.featuresource);
                rulelist = newsimplestyle.rulelist;
            }
            featuresource = curLayer.featuresource;
            Schema schema = featuresource.schema;

            this.geotype = schema.geometryType;
            SetSelectedStyleType(curLayer.style.styletype, this.geotype, curLayer.style, curLayer.featuresource);

            //fieldList.ItemsSource = curLayer.GetFields();
            fieldList.ItemsSource = schema.fields.Keys.ToList();

            //foreach (string attributename in schema.fields.Keys)
            //{
            //    FieldDefn field = null;
            //    if (schema.fields.TryGetValue(attributename, out field))
            //    {
            //        if (field.GetFieldType() == FieldType.OFTReal || field.GetFieldType() == FieldType.OFTInteger)
            //            fieldList.Items.Add(attributename);
            //    }

            //}
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Provide mapping between the OGR and MapServer layer types.
        /// </summary>
        /// <param name="type">The OGR layer type to be converted.</param>
        /// <returns>The corresponding MapServer layer type.</returns>
        public static MS_LAYER_TYPE GetLayerType(wkbGeometryType type)
        {
            switch (type)
            {
            case wkbGeometryType.wkbLineString:
            case wkbGeometryType.wkbLinearRing:
            case wkbGeometryType.wkbLineString25D:
            case wkbGeometryType.wkbMultiLineString:
            case wkbGeometryType.wkbMultiLineString25D:
                return(MS_LAYER_TYPE.MS_LAYER_LINE);

            case wkbGeometryType.wkbMultiPoint:
            case wkbGeometryType.wkbMultiPoint25D:
            case wkbGeometryType.wkbPoint:
            case wkbGeometryType.wkbPoint25D:
                return(MS_LAYER_TYPE.MS_LAYER_POINT);

            case wkbGeometryType.wkbMultiPolygon:
            case wkbGeometryType.wkbMultiPolygon25D:
            case wkbGeometryType.wkbPolygon:
            case wkbGeometryType.wkbPolygon25D:
                return(MS_LAYER_TYPE.MS_LAYER_POLYGON);
            }
            // default setting
            return(MS_LAYER_TYPE.MS_LAYER_POINT);
        }
Ejemplo n.º 5
0
        public static FeatureType ToFeatureType(this  wkbGeometryType geometryType)
        {
            FeatureType featureType = FeatureType.Unknown;

            switch (geometryType)
            {
            case OSGeo.OGR.wkbGeometryType.wkbPoint:
            case OSGeo.OGR.wkbGeometryType.wkbMultiPoint:
                featureType = FeatureType.Point;
                break;

            case OSGeo.OGR.wkbGeometryType.wkbLineString:
            case OSGeo.OGR.wkbGeometryType.wkbMultiLineString:
                featureType = FeatureType.Polyline;
                break;

            case OSGeo.OGR.wkbGeometryType.wkbPolygon:
            case OSGeo.OGR.wkbGeometryType.wkbMultiPolygon:
                featureType = FeatureType.Polygon;
                break;

            default:
                throw new NotImplementedException("暂未实现的类型");
            }
            return(featureType);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 初始化时调用,设置初始的combox的值同时根据styletype初始化对应的styleview
        /// </summary>
        /// <param name="type"></param>
        /// <param name="geotype"></param>
        /// <param name="style"></param>
        /// <param name="featuresource"></param>
        private void SetSelectedStyleType(StyleType type, wkbGeometryType geotype, GisSmartTools.Support.Style style, FeatureSource featuresource)
        {
            switch (type)
            {
            case StyleType.SIMPLESTYLE:
                singleRadio.IsChecked = true;
                break;

            case StyleType.UNIQUESTYLE:
                uniqueRadio.IsChecked = true;
                break;

            case StyleType.RANKSTYLE:
                classRadio.IsChecked = true;
                break;

            case StyleType.CUSTOMSTYLE:

                break;
            }
            List <RenderRule> rulelist = style.rulelist;

            if (rulelist.Count != 0)
            {
                InitializeList(rulelist);
            }
        }
Ejemplo n.º 7
0
        private static OSGeo.OGR.Geometry GetOgrGeometry(wkbGeometryType geometryType, IEnumerable <ICoordinate> coordinates)
        {
            OSGeo.OGR.Geometry ogrGeometry = null;
            var firstCoord = coordinates?.FirstOrDefault();

            if (firstCoord != null)
            {
                ogrGeometry = new OSGeo.OGR.Geometry(geometryType);
                Action <ICoordinate> addCoordAction;
                switch (firstCoord.Dimension)
                {
                case 2:
                    addCoordAction = (coordinate) => ogrGeometry.AddPoint_2D(coordinate.X, coordinate.Y);
                    break;

                case 3:
                    addCoordAction = (coordinate) => ogrGeometry.AddPoint(coordinate.X, coordinate.Y, coordinate.Z);
                    break;

                case 4:
                    addCoordAction = (coordinate) => ogrGeometry.AddPointZM(coordinate.X, coordinate.Y, coordinate.Z, coordinate.M);
                    break;

                default:
                    return(ogrGeometry);
                }
                foreach (var item in coordinates)
                {
                    addCoordAction(item);
                }
            }
            return(ogrGeometry);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 获取数据
        /// </summary>
        /// <returns></returns>
        public bool GetGeometry(int iIndex)
        {
            if (null == oLayer)
            {
                return(false);
            }
            long    iFeatureCout = oLayer.GetFeatureCount(0);
            Feature oFeature     = null;

            oFeature = oLayer.GetFeature(iIndex);
            //  Geometry
            Geometry        oGeometry     = oFeature.GetGeometryRef();
            wkbGeometryType oGeometryType = oGeometry.GetGeometryType();

            switch (oGeometryType)
            {
            case wkbGeometryType.wkbPoint:
                oGeometry.ExportToWkt(out sCoordiantes);
                sCoordiantes = sCoordiantes.ToUpper().Replace("POINT (", "").Replace(")", "");
                break;

            case wkbGeometryType.wkbLineString:
            case wkbGeometryType.wkbLinearRing:
                oGeometry.ExportToWkt(out sCoordiantes);
                sCoordiantes = sCoordiantes.ToUpper().Replace("LINESTRING (", "").Replace(")", "");
                break;

            default:
                break;
            }
            return(false);
        }
Ejemplo n.º 9
0
 public GeomFieldDefn(string name_null_ok, wkbGeometryType field_type) : this(OgrPINVOKE.new_GeomFieldDefn(name_null_ok, (int)field_type), true, null)
 {
     if (OgrPINVOKE.SWIGPendingException.Pending)
     {
         throw OgrPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Ejemplo n.º 10
0
 public Geometry(wkbGeometryType type) : this(OgrPINVOKE.new_Geometry((int)type, null, 0, IntPtr.Zero, null), true, null)
 {
     if (OgrPINVOKE.SWIGPendingException.Pending)
     {
         throw OgrPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Ejemplo n.º 11
0
 public Geometry(wkbGeometryType type, string wkt, int wkb, IntPtr wkb_buf, string gml) : this(OgrPINVOKE.new_Geometry((int)type, wkt, wkb, wkb_buf, gml), true, null)
 {
     if (OgrPINVOKE.SWIGPendingException.Pending)
     {
         throw OgrPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Ejemplo n.º 12
0
        public IGeometry parseWkb(byte[] wkb)
        {
            // Get the bit order conversion.
            BitConversion convertType = getConversionType(wkb);

            // Get the geometry type.
            UInt32 tempInt;
            int    i = 1;

            getWkbUInt32(wkb, ref i, convertType, out tempInt);
            wkbGeometryType geomType = (wkbGeometryType)tempInt;

            IGeometry geom;

            switch (geomType)
            {
            // AO has trouble parsing MultiLinestrings from PostGis.
            // So we need to do it by hand.
            case wkbGeometryType.wkbMultiLinestring:
                geom = parseAoUnsafeWkb(wkb, convertType, geomType);
                break;

            // All other geometries AO can handle.
            default:
                geom = parseAoSafeWkb(wkb);
                break;
            }

            return(geom);
        }
Ejemplo n.º 13
0
    static public bool Calculate2LineCrossing(Vector3 l1start, Vector3 l1end, Vector3 l2start, Vector3 l2end, ref Vector3 crossing)
    {
        bool     r  = false;
        Geometry l1 = new Geometry(wkbGeometryType.wkbLineString);

        l1.AddPoint_2D(l1start.x, l1start.y);
        l1.AddPoint_2D(l1end.x, l1end.y);

        Geometry l2 = new Geometry(wkbGeometryType.wkbLineString);

        l2.AddPoint_2D(l2start.x, l2start.y);
        l2.AddPoint_2D(l2end.x, l2end.y);
        Geometry intersection = l1.Intersection(l2);

        intersection.FlattenTo2D();
        wkbGeometryType t = intersection.GetGeometryType();

        if (wkbGeometryType.wkbPoint == t)
        {
            r          = true;
            crossing.x = (float)intersection.GetX(0);
            crossing.y = (float)intersection.GetY(0);
        }
        return(r);
    }
Ejemplo n.º 14
0
    public void DrawGeometry(Geometry geo)
    {
        Assert.IsNotNull(geo);
        wkbGeometryType t = Ogr.GT_Flatten(geo.GetGeometryType());

        switch (t)
        {
        case wkbGeometryType.wkbUnknown:
            break;

        case wkbGeometryType.wkbPoint:
            break;

        case wkbGeometryType.wkbPolygon:
        {
            DrawPolygon(geo);
        }
        break;

        case wkbGeometryType.wkbLineString:
        {
            DrawLineString(geo);
        }
        break;

        default:
            break;
        }
    }
Ejemplo n.º 15
0
 public void SetType(wkbGeometryType type)
 {
     OgrPINVOKE.GeomFieldDefn_SetType(swigCPtr, (int)type);
     if (OgrPINVOKE.SWIGPendingException.Pending)
     {
         throw OgrPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Ejemplo n.º 16
0
        public static GeometryType ToGeometryType(this wkbGeometryType wkbGeometryType)
        {
            GeometryType geometryType = GeometryType.Unknown;
            string       name         = wkbGeometryType.ToString().Replace("wkb", "");

            Enum.TryParse(name, out geometryType);
            return(geometryType);
        }
Ejemplo n.º 17
0
        public static wkbGeometryType TowWkbGeometryType(this GeometryType geometryType)
        {
            wkbGeometryType wkbGeometryType = wkbGeometryType.wkbUnknown;
            string          name            = $"wkb{geometryType}";

            Enum.TryParse(name, out wkbGeometryType);
            return(wkbGeometryType);
        }
Ejemplo n.º 18
0
 public void SetGeomType(wkbGeometryType geom_type)
 {
     OgrPINVOKE.FeatureDefn_SetGeomType(swigCPtr, (int)geom_type);
     if (OgrPINVOKE.SWIGPendingException.Pending)
     {
         throw OgrPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Ejemplo n.º 19
0
        protected VirgisFeature _drawFeature(Geometry poly, Feature feature = null)
        {
            Geometry center = poly.Centroid();

            center.AssignSpatialReference(poly.GetSpatialReference());


            //Create the GameObjects
            GameObject dataPoly = Instantiate(PolygonPrefab, center.TransformWorld()[0], Quaternion.identity, transform);



            // add the gis data from geoJSON
            Datapolygon p = dataPoly.GetComponent <Datapolygon>();

            if (feature != null)
            {
                p.feature = feature;
            }

            if (symbology.ContainsKey("body") && symbology["body"].ContainsKey("Label") && symbology["body"].Label != null && (feature?.ContainsKey(symbology["body"].Label) ?? false))
            {
                //Set the label
                GameObject labelObject = Instantiate(LabelPrefab, dataPoly.transform, false);
                labelObject.transform.Translate(dataPoly.transform.TransformVector(Vector3.up) * symbology["point"].Transform.Scale.magnitude, Space.Self);
                Text labelText = labelObject.GetComponentInChildren <Text>();
                labelText.text = (string)feature.Get(symbology["body"].Label);
            }


            List <Dataline> polygon     = new List <Dataline>();
            List <Geometry> LinearRings = new List <Geometry>();

            for (int i = 0; i < poly.GetGeometryCount(); i++)
            {
                LinearRings.Add(poly.GetGeometryRef(i));
            }
            // Darw the LinearRing
            foreach (Geometry LinearRing in LinearRings)
            {
                wkbGeometryType type = LinearRing.GetGeometryType();
                if (type == wkbGeometryType.wkbLinearRing || type == wkbGeometryType.wkbLineString25D || type == wkbGeometryType.wkbLineString)
                {
                    GameObject dataLine = Instantiate(LinePrefab, dataPoly.transform, false);
                    Dataline   com      = dataLine.GetComponent <Dataline>();
                    LinearRing.CloseRings();
                    com.Draw(LinearRing, symbology, LinePrefab, HandlePrefab, null, mainMat, selectedMat, lineMain, lineSelected, true);
                    polygon.Add(com);
                }
            }

            //Draw the Polygon
            p.Draw(polygon, bodyMain);

            return(p);
        }
Ejemplo n.º 20
0
        public static int GT_HasM(wkbGeometryType eType)
        {
            int ret = OgrPINVOKE.GT_HasM((int)eType);

            if (OgrPINVOKE.SWIGPendingException.Pending)
            {
                throw OgrPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Ejemplo n.º 21
0
        public static wkbGeometryType GT_SetModifier(wkbGeometryType eType, int bSetZ, int bSetM)
        {
            wkbGeometryType ret = (wkbGeometryType)OgrPINVOKE.GT_SetModifier((int)eType, bSetZ, bSetM);

            if (OgrPINVOKE.SWIGPendingException.Pending)
            {
                throw OgrPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Ejemplo n.º 22
0
        public static int GT_IsSubClassOf(wkbGeometryType eType, wkbGeometryType eSuperType)
        {
            int ret = OgrPINVOKE.GT_IsSubClassOf((int)eType, (int)eSuperType);

            if (OgrPINVOKE.SWIGPendingException.Pending)
            {
                throw OgrPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Ejemplo n.º 23
0
        public static int GT_IsNonLinear(wkbGeometryType arg0)
        {
            int ret = OgrPINVOKE.GT_IsNonLinear((int)arg0);

            if (OgrPINVOKE.SWIGPendingException.Pending)
            {
                throw OgrPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Ejemplo n.º 24
0
        public static wkbGeometryType GT_GetLinear(wkbGeometryType eType)
        {
            wkbGeometryType ret = (wkbGeometryType)OgrPINVOKE.GT_GetLinear((int)eType);

            if (OgrPINVOKE.SWIGPendingException.Pending)
            {
                throw OgrPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Ejemplo n.º 25
0
        public static string GeometryTypeToName(wkbGeometryType eType)
        {
            string ret = OgrPINVOKE.GeometryTypeToName((int)eType);

            if (OgrPINVOKE.SWIGPendingException.Pending)
            {
                throw OgrPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Ejemplo n.º 26
0
        public wkbGeometryType GetGeomType()
        {
            wkbGeometryType ret = (wkbGeometryType)OgrPINVOKE.Layer_GetGeomType(swigCPtr);

            if (OgrPINVOKE.SWIGPendingException.Pending)
            {
                throw OgrPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Ejemplo n.º 27
0
        public Layer CreateLayer(string name, OSGeo.OSR.SpatialReference srs, wkbGeometryType geom_type, string[] options)
        {
            IntPtr cPtr = OgrPINVOKE.DataSource_CreateLayer(swigCPtr, name, OSGeo.OSR.SpatialReference.getCPtr(srs), (int)geom_type, (options != null)? new OgrPINVOKE.StringListMarshal(options)._ar : null);
            Layer  ret  = (cPtr == IntPtr.Zero) ? null : new Layer(cPtr, false, ThisOwn_false());

            if (OgrPINVOKE.SWIGPendingException.Pending)
            {
                throw OgrPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Ejemplo n.º 28
0
        public static Geometry ForceTo(Geometry geom_in, wkbGeometryType eTargetType, string[] options)
        {
            IntPtr   cPtr = OgrPINVOKE.ForceTo(Geometry.getCPtr(geom_in), (int)eTargetType, (options != null)? new OgrPINVOKE.StringListMarshal(options)._ar : null);
            Geometry ret  = (cPtr == IntPtr.Zero) ? null : new Geometry(cPtr, true, ThisOwn_true());

            if (OgrPINVOKE.SWIGPendingException.Pending)
            {
                throw OgrPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Ejemplo n.º 29
0
    static public bool SaveShp(string path, string fanme, wkbGeometryType t, List <Geometry> lstgeo)
    {
        // 为了支持中文路径,请添加下面这句代码
        OSGeo.GDAL.Gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "NO");
        // 为了使属性表字段支持中文,请添加下面这句
        OSGeo.GDAL.Gdal.SetConfigOption("SHAPE_ENCODING", "");

        string strVectorFile = path;

        // 注册所有的驱动
        Ogr.RegisterAll();

        //创建数据,这里以创建ESRI的shp文件为例
        string strDriverName = "ESRI Shapefile";
        Driver oDriver       = Ogr.GetDriverByName(strDriverName);

        if (oDriver == null)
        {
            // Console.WriteLine("%s 驱动不可用!\n", strVectorFile);
            return(false);
        }

        // 创建数据源
        DataSource oDS = oDriver.CreateDataSource(strVectorFile, null);

        if (oDS == null)
        {
            // Console.WriteLine("创建矢量文件【%s】失败!\n", strVectorFile);
            return(false);
        }

        // 创建图层,创建一个多边形图层,这里没有指定空间参考,如果需要的话,需要在这里进行指定
        Layer oLayer = oDS.CreateLayer(fanme, null, t, null);

        if (oLayer == null)
        {
            // Console.WriteLine("图层创建失败!\n");
            return(false);
        }

        FeatureDefn oDefn = oLayer.GetLayerDefn();

        // 创建三角形要素
        foreach (var item in lstgeo)
        {
            Feature oFeatureTriangle = new Feature(oDefn);
            oFeatureTriangle.SetGeometry(item);
            oLayer.CreateFeature(oFeatureTriangle);
        }

        return(true);
    }
Ejemplo n.º 30
0
        public static void CreateShapeFile(MG_Layer mgLayer, string filePath)
        {
            string dataSourceName = filePath;
            string layerName      = Path.GetFileNameWithoutExtension(filePath);

            mgLayer.SetLayerPath(filePath);
            try
            {
                Ogr.RegisterAll();
                string driverName = "ESRI Shapefile";
                Driver driver     = Ogr.GetDriverByName(driverName);

                if (File.Exists(dataSourceName))
                {
                    //System.IO.File.Delete(dataSourceName);// only remove xxx.shp
                    driver.DeleteDataSource(dataSourceName);// reomve xxx.shp dbf shx
                }

                DataSource      ds    = driver.CreateDataSource(dataSourceName, new string[] { });
                wkbGeometryType gt    = TowkbGeometryType(mgLayer.Type);// retrieve data
                Layer           layer = ds.CreateLayer(layerName, null, gt, new string[] { });
                // create three files  xxx.shp xxx.dbf xxx.shx

                // fieldset
                int fieldCount = mgLayer.FieldSet.Count();
                for (int i = 0; i < fieldCount; i++)
                {
                    MG_Field  field = mgLayer.FieldSet.GetAt(i);
                    FieldDefn def   = ToFieldDefn(field);
                    layer.CreateField(def, 1);
                }

                // feature
                int featureCount = mgLayer.GetFeatureCount();
                for (int i = 0; i < featureCount; i++)
                {
                    Feature f = ToFeature(mgLayer.GetFeature(i));
                    layer.CreateFeature(f);
                    f.Dispose();
                }

                // flush data to file
                layer.Dispose();
                ds.Dispose();
                driver.Dispose();
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 31
0
 public static int GT_HasZ(wkbGeometryType eType)
 {
     int ret = OgrPINVOKE.GT_HasZ((int)eType);
     if (OgrPINVOKE.SWIGPendingException.Pending) throw OgrPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
Ejemplo n.º 32
0
 public static Geometry ForceTo(Geometry geom_in, wkbGeometryType eTargetType, string[] options)
 {
     IntPtr cPtr = OgrPINVOKE.ForceTo(Geometry.getCPtr(geom_in), (int)eTargetType, (options != null)? new OgrPINVOKE.StringListMarshal(options)._ar : null);
     Geometry ret = (cPtr == IntPtr.Zero) ? null : new Geometry(cPtr, true, ThisOwn_true());
     if (OgrPINVOKE.SWIGPendingException.Pending) throw OgrPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
Ejemplo n.º 33
0
 /// <summary>
 /// Provide mapping between the OGR and MapServer layer types.
 /// </summary>
 /// <param name="type">The OGR layer type to be converted.</param>
 /// <returns>The corresponding MapServer layer type.</returns>
 public static MS_LAYER_TYPE GetLayerType(wkbGeometryType type)
 {
     switch (type)
     {
         case wkbGeometryType.wkbLineString:
         case wkbGeometryType.wkbLinearRing:
         case wkbGeometryType.wkbLineString25D:
         case wkbGeometryType.wkbMultiLineString:
         case wkbGeometryType.wkbMultiLineString25D:
             return MS_LAYER_TYPE.MS_LAYER_LINE;
         case wkbGeometryType.wkbMultiPoint:
         case wkbGeometryType.wkbMultiPoint25D:
         case wkbGeometryType.wkbPoint:
         case wkbGeometryType.wkbPoint25D:
             return MS_LAYER_TYPE.MS_LAYER_POINT;
         case wkbGeometryType.wkbMultiPolygon:
         case wkbGeometryType.wkbMultiPolygon25D:
         case wkbGeometryType.wkbPolygon:
         case wkbGeometryType.wkbPolygon25D:
             return MS_LAYER_TYPE.MS_LAYER_POLYGON;
     }
     // default setting
     return MS_LAYER_TYPE.MS_LAYER_POINT;
 }
Ejemplo n.º 34
0
 public static string GeometryTypeToName(wkbGeometryType eType) {
   string ret = OgrPINVOKE.GeometryTypeToName((int)eType);
   if (OgrPINVOKE.SWIGPendingException.Pending) throw OgrPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
Ejemplo n.º 35
0
        private static IGeometry parseAoUnsafeWkb(byte[] wkb, BitConversion bitConversion, wkbGeometryType geometryType)
        {
            IGeometry geom = null;

            // Keeps track of what byte we're at.
            // (assume the byte order and geometry
            // type data has already been read)
            int i = 5;

            switch (geometryType)
            {
                case wkbGeometryType.wkbMultiLinestring:
                    createWkbMultiLineString(wkb, ref i, bitConversion, out geom);
                    break;
            }

            return geom;
        }
Ejemplo n.º 36
0
 public void SetType(wkbGeometryType type)
 {
     OgrPINVOKE.GeomFieldDefn_SetType(swigCPtr, (int)type);
     if (OgrPINVOKE.SWIGPendingException.Pending) throw OgrPINVOKE.SWIGPendingException.Retrieve();
 }
Ejemplo n.º 37
0
 public Geometry(wkbGeometryType type, string wkt, int wkb, IntPtr wkb_buf, string gml)
     : this(OgrPINVOKE.new_Geometry((int)type, wkt, wkb, wkb_buf, gml), true, null)
 {
     if (OgrPINVOKE.SWIGPendingException.Pending) throw OgrPINVOKE.SWIGPendingException.Retrieve();
 }
Ejemplo n.º 38
0
 public Geometry(wkbGeometryType type)
     : this(OgrPINVOKE.new_Geometry((int)type, null, 0, IntPtr.Zero, null), true, null)
 {
     if (OgrPINVOKE.SWIGPendingException.Pending) throw OgrPINVOKE.SWIGPendingException.Retrieve();
 }
Ejemplo n.º 39
0
 public static int GT_IsSubClassOf(wkbGeometryType eType, wkbGeometryType eSuperType)
 {
     int ret = OgrPINVOKE.GT_IsSubClassOf((int)eType, (int)eSuperType);
     if (OgrPINVOKE.SWIGPendingException.Pending) throw OgrPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
Ejemplo n.º 40
0
 public static wkbGeometryType GT_SetModifier(wkbGeometryType eType, int bSetZ, int bSetM)
 {
     wkbGeometryType ret = (wkbGeometryType)OgrPINVOKE.GT_SetModifier((int)eType, bSetZ, bSetM);
     if (OgrPINVOKE.SWIGPendingException.Pending) throw OgrPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
Ejemplo n.º 41
0
 public void SetGeomType(wkbGeometryType geom_type)
 {
     OgrPINVOKE.FeatureDefn_SetGeomType(swigCPtr, (int)geom_type);
     if (OgrPINVOKE.SWIGPendingException.Pending) throw OgrPINVOKE.SWIGPendingException.Retrieve();
 }
Ejemplo n.º 42
0
 public static wkbGeometryType GT_SetZ(wkbGeometryType eType)
 {
     wkbGeometryType ret = (wkbGeometryType)OgrPINVOKE.GT_SetZ((int)eType);
     if (OgrPINVOKE.SWIGPendingException.Pending) throw OgrPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
Ejemplo n.º 43
0
        private FeatureType TranslateOgrGeometryType(wkbGeometryType ogrType)
        {
            switch (ogrType)
            {
                case wkbGeometryType.wkbLineString:
                    return FeatureType.Line;

                case wkbGeometryType.wkbPolygon:
                    return FeatureType.Polygon;

                case wkbGeometryType.wkbPoint:
                    return FeatureType.Point;

                case wkbGeometryType.wkbMultiPoint:
                    return FeatureType.MultiPoint;

                default:
                    return FeatureType.Unspecified;
            }
        }
Ejemplo n.º 44
0
 public GeomFieldDefn(string name_null_ok, wkbGeometryType field_type)
     : this(OgrPINVOKE.new_GeomFieldDefn(name_null_ok, (int)field_type), true, null)
 {
     if (OgrPINVOKE.SWIGPendingException.Pending) throw OgrPINVOKE.SWIGPendingException.Retrieve();
 }
Ejemplo n.º 45
0
 public Layer CreateLayer(string name, OSGeo.OSR.SpatialReference srs, wkbGeometryType geom_type, string[] options) {
   IntPtr cPtr = OgrPINVOKE.DataSource_CreateLayer(swigCPtr, name, OSGeo.OSR.SpatialReference.getCPtr(srs), (int)geom_type, (options != null)? new OgrPINVOKE.StringListMarshal(options)._ar : null);
   Layer ret = (cPtr == IntPtr.Zero) ? null : new Layer(cPtr, false, ThisOwn_false());
   if (OgrPINVOKE.SWIGPendingException.Pending) throw OgrPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
Ejemplo n.º 46
0
 public static int GT_IsSurface(wkbGeometryType arg0)
 {
     int ret = OgrPINVOKE.GT_IsSurface((int)arg0);
     if (OgrPINVOKE.SWIGPendingException.Pending) throw OgrPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }