// Start the geometry.
 public void BeginGeometry(OpenGisGeometryType type)
 {
     if (type == OpenGisGeometryType.LineString)
     {
         _currentLine = new LRSLine(_srid);
     }
 }
		public void BeginGeometry(OpenGisGeometryType type)
		{
			if (_geomCollection == null)
			{
				_geomCollection = new SinkGeometryCollection<OpenGisGeometryType>(type);
				if (type == OpenGisGeometryType.GeometryCollection)
				{
					_isGeometryCollection = true;
				}
			}

			_currentGeometry = new SinkGeometry<OpenGisGeometryType>(type);
			if (_isGeometryCollection && _nestLevel > 0)
			{
				if (_nestLevel == 1)
				{
					_geomCollection.SubItems.Add(new SinkGeometryCollection<OpenGisGeometryType>(type));
				}
				_geomCollection.SubItems.Last().Add(_currentGeometry);
			}
			else
			{
				_geomCollection.Add(_currentGeometry);
			}

			_nestLevel++;
		}
        public void BeginGeometry(OpenGisGeometryType type)
        {
            if (_geomCollection == null)
            {
                _geomCollection = new SinkGeometryCollection <OpenGisGeometryType>(type);
                if (type == OpenGisGeometryType.GeometryCollection)
                {
                    _isGeometryCollection = true;
                }
            }

            _currentGeometry = new SinkGeometry <OpenGisGeometryType>(type);
            if (_isGeometryCollection && _nestLevel > 0)
            {
                if (_nestLevel == 1)
                {
                    _geomCollection.SubItems.Add(new SinkGeometryCollection <OpenGisGeometryType>(type));
                }
                _geomCollection.SubItems.Last().Add(_currentGeometry);
            }
            else
            {
                _geomCollection.Add(_currentGeometry);
            }

            _nestLevel++;
        }
Exemplo n.º 4
0
        public static SMGeometry ToSharpMapGeometry(SqlGeometry geometry)
        {
            OpenGisGeometryType geometryType =
                (OpenGisGeometryType)Enum.Parse(typeof(OpenGisGeometryType), (string)geometry.STGeometryType());

            switch (geometryType)
            {
            case OpenGisGeometryType.Point:
                return(SqlGeometryToSharpMapPoint(geometry));

            case OpenGisGeometryType.LineString:
                return(SqlGeometryToSharpMapLineString(geometry));

            case OpenGisGeometryType.Polygon:
                return(SqlGeometryToSharpMapPolygon(geometry));

            case OpenGisGeometryType.MultiPoint:
                return(SqlGeometryToSharpMapMultiPoint(geometry));

            case OpenGisGeometryType.MultiLineString:
                return(SqlGeometryToSharpMapMultiLineString(geometry));

            case OpenGisGeometryType.MultiPolygon:
                return(SqlGeometryToSharpMapMultiPolygon(geometry));

            case OpenGisGeometryType.GeometryCollection:
                return(SqlGeometryToSharpMapGeometryCollection(geometry));
            }
            throw new ArgumentException(string.Format("Cannot convert SqlServer '{0}' to Sharpmap.Geometry", geometry.STGeometryType()), "geometry");
        }
Exemplo n.º 5
0
        public static IGeometry SqlGeometryToGeometry(SqlGeometry geom, GeometryFactory factory)
        {
            if (geom.STIsEmpty())
            {
                return(factory.CreateGeometryCollection(null));
            }

            OpenGisGeometryType geometryType = (OpenGisGeometryType)Enum.Parse(typeof(OpenGisGeometryType), geom.STGeometryType().Value);

            switch (geometryType)
            {
            case OpenGisGeometryType.Point:
                return(SqlGeometryToGeometryPoint(geom, factory));

            case OpenGisGeometryType.LineString:
                return(SqlGeometryToGeometryLineString(geom, factory));

            case OpenGisGeometryType.Polygon:
                return(SqlGeometryToGeometryPolygon(geom, factory));

            case OpenGisGeometryType.MultiPoint:
                return(SqlGeometryToGeometryMultiPoint(geom, factory));

            case OpenGisGeometryType.MultiLineString:
                return(SqlGeometryToGeometryMultiLineString(geom, factory));

            case OpenGisGeometryType.MultiPolygon:
                return(SqlGeometryToGeometryMultiPolygon(geom, factory));

            case OpenGisGeometryType.GeometryCollection:
                return(SqlGeometryToGeometryGeometryCollection(geom, factory));
            }

            throw new ArgumentException(string.Format("Cannot convert SqlServer '{0}' to Geometry", geom.STGeometryType()), "geom");
        }
 // Start the geometry.  Throw if it isn't a LineString.
 public void BeginGeometry(OpenGisGeometryType type)
 {
     if (type != OpenGisGeometryType.LineString)
     {
         throw new ArgumentException("This operation may only be executed on LineString instances.");
     }
 }
        private void BuildGeometry(SqlGeometry geom, int ssi)
        {
            int pc;
            OpenGisGeometryType gtype = (OpenGisGeometryType)Enum.Parse(typeof(OpenGisGeometryType), geom.STGeometryType().Value);

            if (!geom.STIsEmpty())
            {
                if (gtype == OpenGisGeometryType.GeometryCollection)
                {
                    this._builder.BeginGeometry(gtype);
                    pc = geom.STNumGeometries().Value;
                    for (int gi = 1; gi <= pc; gi++)
                    {
                        BuildGeometry(geom.STGeometryN(gi), ssi);
                        ssi += geom.STGeometryN(gi).STNumPoints().Value;
                    }
                    this._builder.EndGeometry();
                }
                else
                {
                    this._builder.BeginGeometry(gtype);
                    BuildFigure(geom, ssi);
                    this._builder.EndGeometry();
                }
            }
            else
            {
                this._builder.BeginGeometry(gtype);
                this._builder.EndGeometry();
            }
        }
Exemplo n.º 8
0
        private static bool AreConsistent(ShapeType esriType, OpenGisGeometryType ogcType)
        {
            switch (ogcType)
            {
            case OpenGisGeometryType.Point:
                return(esriType == ShapeType.Point || esriType == ShapeType.PointM || esriType == ShapeType.PointZ);

            case OpenGisGeometryType.MultiLineString:
            case OpenGisGeometryType.LineString:
                return(esriType == ShapeType.PolyLine || esriType == ShapeType.PolyLineM || esriType == ShapeType.PolyLineZ);

            case OpenGisGeometryType.Polygon:
            case OpenGisGeometryType.MultiPolygon:
                return(esriType == ShapeType.Polygon || esriType == ShapeType.PolygonM || esriType == ShapeType.PolygonZ);

            case OpenGisGeometryType.MultiPoint:
                return(esriType == ShapeType.MultiPoint || esriType == ShapeType.MultiPointM || esriType == ShapeType.MultiPointZ);

            case OpenGisGeometryType.GeometryCollection:
            case OpenGisGeometryType.CircularString:
            case OpenGisGeometryType.CompoundCurve:
            case OpenGisGeometryType.CurvePolygon:
            default:
                return(false);
            }
        }
Exemplo n.º 9
0
 // Start the geometry.
 public void BeginGeometry(OpenGisGeometryType type)
 {
     if (type == OpenGisGeometryType.LineString)
     {
         CurrentLine = new LRSLine();
         CurrentLine.SetSrid(Srid);
     }
 }
Exemplo n.º 10
0
 public void BeginGeometry(OpenGisGeometryType type)
 {
     if (_count == 0)
     {
         _sink.BeginGeography(OpenGisGeographyType.MultiPoint);
     }
     _count++;
 }
Exemplo n.º 11
0
 public void EndFigure()
 {
     OpenGisGeometryType type = this.types.Peek();
     if (type == OpenGisGeometryType.Polygon)
     {
         this.rings.Add(this.coordinates.ToArray());
     }
     this.inFigure = false;
 }
Exemplo n.º 12
0
        // Just pass through target.
        public void BeginGeometry(OpenGisGeometryType type)
        {
            if (type == OpenGisGeometryType.Point)
            {
                _isPoint = true;
            }

            _target.BeginGeometry(type);
        }
		public void BeginGeometry(OpenGisGeometryType type)
		{
			if (_geomCollection == null)
			{
				_geomCollection = new SinkGeometryCollection<OpenGisGeometryType>(type);
			}

			_currentGeometry = new SinkGeometry<OpenGisGeometryType>(type);
		}
Exemplo n.º 14
0
        private void BuildFigure(SqlGeometry geom, int ssi)
        {
            int pc, si = ssi;
            OpenGisGeometryType gtype = (OpenGisGeometryType)Enum.Parse(typeof(OpenGisGeometryType), geom.STGeometryType().Value);

            switch (gtype)
            {
            case OpenGisGeometryType.Point:
                this._builder.BeginFigure(_xy[si], _xy[si + 1], geom.HasZ ? (double?)_z[si] : null, geom.HasM ? (double?)_m[si] : null);
                this._builder.EndFigure();
                break;

            case OpenGisGeometryType.LineString:
                BuildLineString(geom, si);
                break;

            case OpenGisGeometryType.Polygon:
                BuildLineString(geom.STExteriorRing(), si);
                pc  = geom.STNumInteriorRing().Value;
                si += geom.STExteriorRing().STNumPoints().Value;
                for (int i = 1; i <= pc; i++)
                {
                    si += geom.STInteriorRingN(i).STNumPoints().Value;
                    BuildLineString(geom.STInteriorRingN(i), si);
                }
                break;

            case OpenGisGeometryType.CircularString:
                BuildCircularString(geom, si);
                break;

            case OpenGisGeometryType.CompoundCurve:
                BuildCompoundCurve(geom, si);
                break;

            case OpenGisGeometryType.CurvePolygon:
                BuildFigure(geom.STExteriorRing(), si);
                pc  = geom.STNumInteriorRing().Value;
                si += geom.STExteriorRing().STNumPoints().Value;
                for (int i = 1; i <= pc; i++)
                {
                    si += geom.STInteriorRingN(i).STNumPoints().Value;
                    BuildFigure(geom.STInteriorRingN(i), si);
                }
                break;

            default:
                pc = geom.STNumGeometries().Value;
                for (int gi = 1; gi <= pc; gi++)
                {
                    BuildGeometry(geom.STGeometryN(gi), si);
                    si += geom.STGeometryN(gi).STNumPoints().Value;
                }
                break;
            }
        }
 private void AddGeometryCollection(IGeometry geometry, OpenGisGeometryType type)
 {
     builder.BeginGeometry(type);
     IGeometryCollection coll = geometry as IGeometryCollection;
     Array.ForEach<IGeometry>(coll.Geometries, delegate(IGeometry g)
     {
         AddGeometry(g);
     });
     builder.EndGeometry();
 }
        private void AddGeometryCollection(IGeometry geometry, OpenGisGeometryType type)
        {
            builder.BeginGeometry(type);
            IGeometryCollection coll = geometry as IGeometryCollection;

            Array.ForEach <IGeometry>(coll.Geometries, delegate(IGeometry g)
            {
                AddGeometry(g);
            });
            builder.EndGeometry();
        }
 // Start geometry and check if the type is of the supported types
 public void BeginGeometry(OpenGisGeometryType type)
 {
     if (type == OpenGisGeometryType.MultiLineString)
     {
         _isMultiLine = true;
     }
     else if (type == OpenGisGeometryType.LineString)
     {
         _lineCounter++;
     }
 }
Exemplo n.º 18
0
 public void BeginGeometry(OpenGisGeometryType type)
 {
     if (_root)
     {
         _root = false;
         _sink.BeginGeometry(type);
     }
     else
     {
         _types.Enqueue(type);
     }
 }
Exemplo n.º 19
0
        public static SqlGeometry Project(this SqlGeography geography, Func <IPoint, IPoint> mapFunction, int newSrid = 0)
        {
            SqlGeometryBuilder builder = new SqlGeometryBuilder();

            builder.SetSrid(newSrid);

            geography = geography.MakeValid();

            OpenGisGeometryType geometryType = (OpenGisGeometryType)Enum.Parse(typeof(OpenGisGeometryType), geography.STGeometryType().Value, true);

            builder.BeginGeometry(geometryType);

            switch (geometryType)
            {
            case OpenGisGeometryType.CircularString:
            case OpenGisGeometryType.CompoundCurve:
            case OpenGisGeometryType.CurvePolygon:
            case OpenGisGeometryType.GeometryCollection:
                throw new NotImplementedException();

            case OpenGisGeometryType.LineString:
                ProjectLineString(builder, geography, mapFunction);
                break;

            case OpenGisGeometryType.MultiLineString:
                ProjectMultiLineSring(builder, geography, mapFunction);
                break;

            case OpenGisGeometryType.MultiPoint:
                ProjectMultiPoint(builder, geography, mapFunction);
                break;

            case OpenGisGeometryType.MultiPolygon:
                ProjectMultiPolygon(builder, geography, mapFunction);
                break;

            case OpenGisGeometryType.Point:
                ProjectPoint(builder, geography, mapFunction);
                break;

            case OpenGisGeometryType.Polygon:
                ProjectPolygon(builder, geography, mapFunction);
                break;

            default:
                throw new NotImplementedException();
            }

            builder.EndGeometry();

            return(builder.ConstructedGeometry.STIsValid().IsTrue ? builder.ConstructedGeometry : builder.ConstructedGeometry.MakeValid());
        }
Exemplo n.º 20
0
        // Check for types and begin geometry accordingly.
        public void BeginGeometry(OpenGisGeometryType type)
        {
            // check if the type is of the supported types
            if (type == OpenGisGeometryType.MultiLineString)
            {
                _isMultiLine = true;
            }

            if (type == OpenGisGeometryType.LineString)
            {
                _lineCounter++;
            }
        }
Exemplo n.º 21
0
 public MapFeature(Placemark placemark, int Id)
 {
     this.placemark = placemark;
     if (placemark.Name != null)
     {
         Name = placemark.Name;
     }
     this.Id      = Id;
     GeometryType = SetGeometryType(placemark);
     InitializeCoordinates(placemark);
     InitializeData(placemark);
     SantizeData();
 }
Exemplo n.º 22
0
        /// <summary>
        /// Loop through each geometry types in geom collection and validate if the type is either POINT, LINESTRING, MULTILINESTRING
        /// </summary>
        /// <param name="type">Geometry Type</param>
        public void BeginGeometry(OpenGisGeometryType type)
        {
            if (type == OpenGisGeometryType.GeometryCollection)
            {
                return;
            }

            // check if the type is of the supported types
            if (_isSupportedType && !(type.Contains(_supportedTypes)))
            {
                _isSupportedType = false;
            }
        }
 /// <summary>
 /// Loop through each geometry types in geom collection and validate if the type is LINESTRING
 /// </summary>
 /// <param name="type">Geometry Type</param>
 public void BeginGeometry(OpenGisGeometryType type)
 {
     if (type == OpenGisGeometryType.LineString)
     {
         if (_isFirstSegment)
         {
             _target.BeginGeometry(type);
         }
     }
     else
     {
         throw new System.Exception("Line string is the only supported type");
     }
 }
Exemplo n.º 24
0
        public static SMGeometry ToSharpMapGeometry(SqlGeometry geometry, Factory factory)
        {
            if (geometry == null)
            {
                return(null);
            }
            if (geometry.IsNull)
            {
                return(null);
            }

            var fact = factory ?? Services.CreateGeometryFactory((int)geometry.STSrid);

            if (geometry.STIsEmpty())
            {
                return(fact.CreateGeometryCollection(null));
            }

            if (!geometry.STIsValid())
            {
                geometry = geometry.MakeValid();
            }

            OpenGisGeometryType geometryType = (OpenGisGeometryType)Enum.Parse(typeof(OpenGisGeometryType), (string)geometry.STGeometryType());

            switch (geometryType)
            {
            case OpenGisGeometryType.Point:
                return(SqlGeometryToSharpMapPoint(geometry, fact));

            case OpenGisGeometryType.LineString:
                return(SqlGeometryToSharpMapLineString(geometry, fact));

            case OpenGisGeometryType.Polygon:
                return(SqlGeometryToSharpMapPolygon(geometry, fact));

            case OpenGisGeometryType.MultiPoint:
                return(SqlGeometryToSharpMapMultiPoint(geometry, fact));

            case OpenGisGeometryType.MultiLineString:
                return(SqlGeometryToSharpMapMultiLineString(geometry, fact));

            case OpenGisGeometryType.MultiPolygon:
                return(SqlGeometryToSharpMapMultiPolygon(geometry, fact));

            case OpenGisGeometryType.GeometryCollection:
                return(SqlGeometryToSharpMapGeometryCollection(geometry, fact));
            }
            throw new ArgumentException(string.Format("Cannot convert SqlServer '{0}' to Sharpmap.Geometry", geometry.STGeometryType()), "geometry");
        }
        public void BeginGeometry(OpenGisGeometryType type)
        {
            _types.Push(type);

            switch (type)
            {
            case OpenGisGeometryType.GeometryCollection:
            case OpenGisGeometryType.MultiPoint:
            case OpenGisGeometryType.MultiLineString:
            case OpenGisGeometryType.MultiPolygon:
                _ccGeometries = new List <IGeometry>();
                _ccGeometriesStack.Push(_ccGeometries);
                break;
            }
        }
        /// <summary>
        /// This method will be called when the geometry instance is finalized
        /// </summary>
        public void EndGeometry()
        {
            // Gets the type of the geometry instance which should be finalized
            OpenGisGeometryType type = m_Context.Type;

            m_Context.EndSpatialObject();

            if (type == OpenGisGeometryType.Point ||
                type == OpenGisGeometryType.LineString)
            {
                EndElement();
            }

            EndElement();
        }
 // Start the geometry.  Throw if it isn't a LineString.
 public void BeginGeometry(OpenGisGeometryType type)
 {
     if (type != OpenGisGeometryType.LineString)
     {
         throw new ArgumentException("This operation may only be executed on LineString instances.");
     }
     if (_startMeasure == _endMeasure)
     {
         _target.BeginGeometry(OpenGisGeometryType.Point);
     }
     else
     {
         _target.BeginGeometry(OpenGisGeometryType.LineString);
     }
 }
Exemplo n.º 28
0
        public void EndGeometry()
        {
            IGeometry geometry = null;

            OpenGisGeometryType type = this.types.Pop();

            switch (type)
            {
            case OpenGisGeometryType.Point:
                geometry = BuildPoint();
                break;

            case OpenGisGeometryType.LineString:
                geometry = BuildLineString();
                break;

            case OpenGisGeometryType.Polygon:
                geometry = BuildPolygon();
                break;

            case OpenGisGeometryType.MultiPoint:
                geometry = BuildMultiPoint();
                break;

            case OpenGisGeometryType.MultiLineString:
                geometry = BuildMultiLineString();
                break;

            case OpenGisGeometryType.MultiPolygon:
                geometry = BuildMultiPolygon();
                break;

            case OpenGisGeometryType.GeometryCollection:
                geometry = BuildGeometryCollection();
                break;
            }

            if (this.types.Count == 0)
            {
                this.geometry      = geometry;
                this.geometry.SRID = this.srid;
            }
            else
            {
                this.geometries.Add(geometry);
            }
        }
Exemplo n.º 29
0
 public void BeginGeometry(OpenGisGeometryType type)
 {
     if (type == OpenGisGeometryType.Point || type == OpenGisGeometryType.MultiPoint)
     {
         if (_root)
         {
             _root = false;
             _sink.BeginGeometry(OpenGisGeometryType.GeometryCollection);
             _sink.EndGeometry();
         }
         _depth++;
     }
     else
     {
         _sink.BeginGeometry(type);
     }
 }
Exemplo n.º 30
0
        private void ReprojectGeometry(SqlGeometry geom, SqlGeometryBuilder bldr)
        {
            if (geom.STIsEmpty())
            {
                bldr.BeginGeometry(OpenGisGeometryType.GeometryCollection);
                bldr.EndGeometry();
            }
            else
            {
                OpenGisGeometryType geometryType = (OpenGisGeometryType)Enum.Parse(typeof(OpenGisGeometryType), geom.STGeometryType().Value);
                switch (geometryType)
                {
                case OpenGisGeometryType.Point:
                    ReprojectPoint(geom, bldr);
                    break;

                case OpenGisGeometryType.LineString:
                    ReprojectLineString(geom, bldr);
                    break;

                case OpenGisGeometryType.Polygon:
                    ReprojectPolygon(geom, bldr);
                    break;

                case OpenGisGeometryType.MultiPoint:
                    ReprojectMultiPoint(geom, bldr);
                    break;

                case OpenGisGeometryType.MultiLineString:
                    ReprojectMultiLineString(geom, bldr);
                    break;

                case OpenGisGeometryType.MultiPolygon:
                    ReprojectMultiPolygon(geom, bldr);
                    break;

                case OpenGisGeometryType.GeometryCollection:
                    ReprojectGeometryCollection(geom, bldr);
                    break;

                default:
                    throw new ArgumentException(string.Format("Cannot reproject SqlServer Type '{0}'", geom.STGeometryType()), "geom");
                }
            }
        }
Exemplo n.º 31
0
        // Start the geometry.
        public void BeginGeometry(OpenGisGeometryType type)
        {
            if (type == OpenGisGeometryType.Point)
            {
                return;
            }

            if (type != OpenGisGeometryType.LineString)
            {
                SpatialExtensions.ThrowException(ErrorMessage.LineStringCompatible);
            }

            if (_isFirstPoint)
            {
                _isFirstPoint = false;
                _target.BeginGeometry(OpenGisGeometryType.MultiLineString);
            }
            _target.BeginGeometry(type);
            _linesCount--;
        }
        /// <summary>
        /// This method will be called when a new geometry instance is passed to the sink
        /// </summary>
        /// <param name="type">Geometry type</param>
        public void BeginGeometry(OpenGisGeometryType type)
        {
            m_Context.BeginSpatialObject(type);

            switch (type)
            {
            case OpenGisGeometryType.Point:
            {
                StartElement("Point");
                StartElement("coordinates");
                break;
            }

            case OpenGisGeometryType.LineString:
            {
                StartElement("LineString");
                StartElement("coordinates");
                break;
            }

            case OpenGisGeometryType.Polygon:
            {
                StartElement("Polygon");
                break;
            }

            case OpenGisGeometryType.MultiPoint:
            case OpenGisGeometryType.MultiLineString:
            case OpenGisGeometryType.MultiPolygon:
            case OpenGisGeometryType.GeometryCollection:
            {
                StartElement("MultiGeometry");
                break;
            }

            default:
            {
                throw new KMLException("Type not supported: " + type.ToString());
            }
            }
        }
Exemplo n.º 33
0
        public static IShape ParseToEsriShape(this SqlGeometry geometry, Func <IPoint, IPoint> mapFunction = null)
        {
            if (geometry.IsNotValidOrEmpty())
            {
                throw new NotImplementedException();
            }

            OpenGisGeometryType geometryType = geometry.GetOpenGisType();

            switch (geometryType)
            {
            case OpenGisGeometryType.CircularString:
            case OpenGisGeometryType.CompoundCurve:
            case OpenGisGeometryType.CurvePolygon:
            case OpenGisGeometryType.GeometryCollection:
            default:
                throw new NotImplementedException();

            case OpenGisGeometryType.LineString:
                return(LineStringOrMultiLineStringToEsriPolyline(geometry, mapFunction));

            case OpenGisGeometryType.MultiLineString:
                return(LineStringOrMultiLineStringToEsriPolyline(geometry, mapFunction));

            case OpenGisGeometryType.MultiPoint:
                return(MultiPointToEsriMultiPoint(geometry, mapFunction));

            case OpenGisGeometryType.MultiPolygon:
                return(PolygonToEsriPolygon(geometry, mapFunction));


            case OpenGisGeometryType.Point:
                return(PointToEsriPoint(geometry, mapFunction));

            case OpenGisGeometryType.Polygon:
                return(PolygonToEsriPolygon(geometry, mapFunction));
            }
        }
		void IGeometrySink.BeginGeometry(OpenGisGeometryType type)
		{
			_sink.BeginGeometry(type);
		}
		public void BeginGeometry(OpenGisGeometryType type)
		{
			_curType = type;
		}
Exemplo n.º 36
0
        public void BeginGeometry(OpenGisGeometryType type)
        {
            _types.Push(type);

            switch (type)
            {
                case OpenGisGeometryType.GeometryCollection:
                case OpenGisGeometryType.MultiPoint:
                case OpenGisGeometryType.MultiLineString:
                case OpenGisGeometryType.MultiPolygon:
                    _ccGeometries = new List<IGeometry>();
                    _ccGeometriesStack.Push(_ccGeometries);
                    break;
            }
        }
 public void BeginGeometry(OpenGisGeometryType type)
 {
     this.types.Push(type);
 }
		void IGeometrySink.BeginGeometry(OpenGisGeometryType type)
		{
			_builder.BeginGeometry(type);
		}