/// <summary>
        /// Creates a new MapCSS object with a geometry object.
        /// </summary>
        /// <param name="geometry"></param>
        public MapCSSObject(Geometry geometry)
        {
            if (geometry == null) throw new ArgumentNullException();

            this.Geometry = geometry;

            if (!(this.Geometry is LineairRing ||
                this.Geometry is Polygon ||
                this.Geometry is MultiPolygon ||
                this.Geometry is LineString))
            {
                throw new Exception("Invalid MapCSS type.");
            }
        }
Exemple #2
0
        /// <summary>
        /// Generates GeoJson for the given geometry.
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="geometry"></param>
        internal static void Write(JsonWriter writer, Geometry geometry)
        {
            if (writer == null) { throw new ArgumentNullException("writer"); }
            if (geometry == null) { throw new ArgumentNullException("geometry"); }

            if (geometry is LineairRing)
            {
                GeoJsonConverter.Write(writer, geometry as LineairRing);
            }
            else if (geometry is Point)
            {
                GeoJsonConverter.Write(writer, geometry as Point);
            }
            else if (geometry is LineString)
            {
                GeoJsonConverter.Write(writer, geometry as LineString);
            }
            else if (geometry is Polygon)
            {
                GeoJsonConverter.Write(writer, geometry as Polygon);
            }
            else if (geometry is MultiPoint)
            {
                GeoJsonConverter.Write(writer, geometry as MultiPoint);
            }
            else if (geometry is MultiPolygon)
            {
                GeoJsonConverter.Write(writer, geometry as MultiPolygon);
            }
            else if (geometry is MultiLineString)
            {
                GeoJsonConverter.Write(writer, geometry as MultiLineString);
            }
            else if (geometry is GeometryCollection)
            {
                GeoJsonConverter.Write(writer, geometry as GeometryCollection);
            }
            else
            {
                throw new Exception(string.Format("Unknown geometry of type: {0}", geometry.GetType()));
            }
        }
Exemple #3
0
        /// <summary>
        /// Adds the given geometry.
        /// </summary>
        private void AddGeometry(Geometry geometry, int color, float width, bool fill)
        {
            if (geometry == null) { throw new ArgumentNullException(); }

            if (geometry is Point)
            {
                this.AddGeometry(geometry as Point, color, width);
            }
            else if (geometry is Polygon)
            {
                this.AddGeometry(geometry as Polygon, color, width, fill);
            }
            else if (geometry is LineString)
            {
                this.AddGeometry(geometry as LineString, color, width);
            }
            else if (geometry is LineairRing)
            {
                this.AddGeometry(geometry as LineairRing, color, width, fill);
            }
        }