Esempio n. 1
0
        ToNtsFeature(this CoreSpatial.IFeature feature, List <string> fieldNames)
        {
            NetTopologySuite.Geometries.Geometry geometry = null;
            var geo = feature.Geometry;

            switch (geo.GeometryType)
            {
            case GeometryType.Point:
            {
                var basicGeometry = (GeoPoint)geo.BasicGeometry;
                geometry = (NetTopologySuite.Geometries.Geometry)ToNtsPoint(basicGeometry);
                break;
            }

            case GeometryType.MultiPoint:
            {
                var basicGeometry = (CoreSpatial.BasicGeometrys.MultiPoint)geo.BasicGeometry;
                geometry = ToNtsMultiPoint(basicGeometry);
                break;
            }

            case GeometryType.PolyLine:
            {
                var basicGeometry = (CoreSpatial.BasicGeometrys.PolyLine)geo.BasicGeometry;
                geometry = basicGeometry.IsLineRing ? ToNtsLinearRing(basicGeometry) : ToNtsLineString(basicGeometry);
                break;
            }

            case GeometryType.MultiPolyLine:
            {
                var basicGeometry = (CoreSpatial.BasicGeometrys.MultiPolyLine)geo.BasicGeometry;
                geometry = ToNtsMultiLineString(basicGeometry);
                break;
            }

            case GeometryType.Polygon:
            {
                var basicGeometry = (CoreSpatial.BasicGeometrys.Polygon)geo.BasicGeometry;
                geometry = ToNtsPolygon(basicGeometry);
                break;
            }

            default:
                throw new Exception("not support GeometryType");
            }

            var attrTable = feature.ToNtsAttributeTable(fieldNames);
            var result    = new NetTopologySuite.Features.Feature(geometry, attrTable);

            return(result);
        }
Esempio n. 2
0
        private static IAttributesTable ToNtsAttributeTable(this CoreSpatial.IFeature feature, List <string> fieldNames)
        {
            var attrDict = new Dictionary <string, object>();
            var dataRow  = feature.DataRow;

            for (int i = 0; i < fieldNames.Count; i++)
            {
                var val = dataRow[i];
                attrDict.Add(fieldNames[i], val);
            }

            IAttributesTable result = new AttributesTable(attrDict);

            return(result);
        }