Exemplo n.º 1
0
            public void Setup()
            {
                if (Sequence == "Raw")
                {
                    var ordinateGroups = new[] { Ordinates.XY };
                    NtsGeometryServices.Instance = new NtsGeometryServices(new RawCoordinateSequenceFactory(ordinateGroups), new PrecisionModel(), 0);
                }
                else if (Sequence == "DotSpatial")
                {
                    NtsGeometryServices.Instance = new NtsGeometryServices(new DotSpatialAffineCoordinateSequenceFactory(Ordinates.XY), new PrecisionModel(), 0);
                }
                else if (Sequence == "FlatGeobuf")
                {
                    NtsGeometryServices.Instance = new NtsGeometryServices(new FlatGeobufCoordinateSequenceFactory(), new PrecisionModel(), 0);
                }
                var  geometryType = GeometryType.LineString;
                byte dimensions   = 2;
                var  headerBuffer = FeatureCollectionConversions.BuildHeader(1, geometryType, dimensions, null, null);

                headerBuffer.Position += 4;
                header = Header.GetRootAsHeader(headerBuffer);
                var geometry = MakeLineString(Vertices);

                feature         = new NetTopologySuite.Features.Feature(geometry, null);
                bytes           = FeatureConversions.ToByteBuffer(feature, ref header);
                bytes.Position += 4;
                feature         = FeatureConversions.FromByteBuffer(bytes, ref header);
            }
Exemplo n.º 2
0
        private static CoreSpatial.IFeature ToCsFeature(this NetTopologySuite.Features.IFeature feature)
        {
            var            originalGeom  = feature.Geometry;
            IBasicGeometry basicGeometry = null;

            switch (originalGeom.OgcGeometryType)
            {
            case OgcGeometryType.Point:
            {
                basicGeometry = ((Point)originalGeom).TcsGeometry();
                break;
            }

            case OgcGeometryType.MultiPoint:
            {
                basicGeometry = ((MultiPoint)originalGeom).TcsGeometry();
                break;
            }

            case OgcGeometryType.LineString:
            {
                if (originalGeom.GeometryType == "LinearRing")
                {
                    basicGeometry = ((LinearRing)originalGeom).TcsGeometry();
                }
                else
                {
                    basicGeometry = ((LineString)originalGeom).TcsGeometry();
                }
                break;
            }

            case OgcGeometryType.MultiLineString:
            {
                basicGeometry = ((MultiLineString)originalGeom).TcsGeometry();

                break;
            }

            case OgcGeometryType.Polygon:
            {
                basicGeometry = ((Polygon)originalGeom).TcsGeometry();
                break;
            }

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

            IGeometry geometry = new Geometry(basicGeometry);
            var       result   = new Feature(geometry);

            return(result);
        }