/// <summary>
		/// Initializes a new instance of the <see cref="LegendItemViewModel"/> class from a <see cref="LegendItemInfo"/>.
		/// </summary>
		/// <param name="legendItemInfo">The legend item info.</param>
		/// <param name="geometryType">Type of the geometry.</param>
		internal LegendItemViewModel(LegendItemInfo legendItemInfo, GeometryType geometryType)
			: this()
		{
			Label = legendItemInfo.Label;
			Symbol = legendItemInfo.Symbol;
			GeometryType = geometryType;
		}
        public override void GetSymbolResourceDictionaryEntriesAsync(GeometryType geometryType, object userState)
        {
            if (m_symbolResourceDictionaries != null)
            {
                List<SymbolResourceDictionaryEntry> resourceDictionaries = new List<SymbolResourceDictionaryEntry>();
                foreach (SymbolResourceDictionaryEntry entry in m_symbolResourceDictionaries)
                {
                    if (entry.GeometryType == geometryType || (entry.GeometryType == GeometryType.Point && geometryType == GeometryType.MultiPoint))
                        resourceDictionaries.Add(entry);
                }
                OnGetResourceDictionariesCompleted(new GetSymbolResourceDictionaryEntriesCompletedEventArgs() { SymbolResourceDictionaries = resourceDictionaries, UserState = userState });
                return;
            }

            #region Validation
            if (ConfigFileUrl == null)
            {
                base.OnGetResourceDictionariesFailed(new ExceptionEventArgs(Resources.Strings.ExceptionConfigFileUrlMustBeSpecified, userState));
                return;
            }

            if (SymbolFolderParentUrl == null)
            {
                base.OnGetResourceDictionariesFailed(new ExceptionEventArgs(Resources.Strings.ExceptionSymbolFolderParentUrlMustBeSpecified, userState));
                return;
            }
            #endregion

            getSymbolResourceDictionaryEntries(geometryType, userState, (o, e) => {                
                OnGetResourceDictionariesCompleted(e);
            }, (o, e) => {
                    OnGetResourceDictionariesFailed(e);
            });
        }
        public static SmGeometries.GeometryType2 Convert(GeometryType type)
        {
            switch (type)
            {
            case GeometryType.GeometryCollection:
                return SmGeometries.GeometryType2.GeometryCollection;
            case GeometryType.LineString:
                return SmGeometries.GeometryType2.LineString;
            case GeometryType.MultiLineString:
                return SmGeometries.GeometryType2.MultiLineString;
            case GeometryType.MultiPoint:
                return SmGeometries.GeometryType2.MultiPoint;
            case GeometryType.MultiPolygon:
                return SmGeometries.GeometryType2.MultiPolygon;
            case GeometryType.Point:
                return SmGeometries.GeometryType2.Point;
            case GeometryType.Polygon:
                return SmGeometries.GeometryType2.Polygon;
            }

            throw new NotSupportedException(
                string.Format(
                    CultureInfo.CurrentCulture,
                    SR.UnsupportedGeometryTypeException,
                    type
                )
            );
        }
Exemple #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RenderEventArg"/> class.
 /// </summary>
 /// <param name="renderMode">render mode.</param>
 /// <param name="camera">camera used during rendering.</param>
 /// <param name="pickingGeometryType">Target geometry type(point, line, triangle, quad or polygon) for color-coded-picking when <paramref name="renderMode"/> is <see cref="RenderModes.ColorCodedPicking"/>; otherwise useless.</param>
 public RenderEventArg(RenderModes renderMode, Rectangle viewport, ICamera camera, GeometryType pickingGeometryType = GeometryType.Point)
 {
     this.RenderMode = renderMode;
     this.CanvasRect = viewport;
     this.Camera = camera;
     this.PickingGeometryType = pickingGeometryType;
 }
Exemple #5
0
        internal static void Populate(IGeometrySink sink, IList<PointNode> points, GeometryType type)
        {
            if (points.Count>0)
            {
                if (type!=GeometryType.LineString)
                    sink.BeginGeometry(GeometryType.Point);

                sink.BeginFigure(points[0].X, points[0].Y, null);
                if (type==GeometryType.MultiPoint)
                    sink.EndFigure();

                for (int i=1; i<points.Count; ++i)
                    if (type==GeometryType.MultiPoint)
                    {
                        sink.BeginFigure(points[i].X, points[i].Y, null);
                        sink.EndFigure();
                    } else
                        sink.AddLine(points[i].X, points[i].Y, null);

                if (type!=GeometryType.MultiPoint)
                    sink.EndFigure();

                if (type!=GeometryType.LineString)
                    sink.EndGeometry();
            }
        }
 public static void SetGeometryType(GraphicsLayer graphicsLayer, GeometryType value)
 {
     if (graphicsLayer == null)
     {
         throw new ArgumentNullException("graphicsLayer");
     }
     graphicsLayer.SetValue(GeometryTypeProperty, value);
 }
Exemple #7
0
        public GeoFeature(object geometry, GeometryType type, IDictionary<string, string> values = null)
        {
            if (geometry == null)
                throw new ArgumentNullException("geometry");

            Geometry = geometry;
            GeometryType = type;
            Fields = values;
        }
Exemple #8
0
        protected override void WriteWktType(GeometryType geometryType, Dimension dimension, bool isEmpty)
        {
            wktBuilder.Append(geometryType.ToString().ToUpperInvariant());

            if (dimension == Dimension.Xym)
                wktBuilder.Append("M");

            if (isEmpty)
                wktBuilder.Append(" EMPTY");
        }
        public static Symbol GetDefaultSymbolClone(this IRenderer renderer, GeometryType type)
        {
            if (renderer != null)
            {
                Symbol defaultSymbol = renderer.GetDefaultSymbol();
                if (defaultSymbol != null) //if a default symbol already exists, clone it
                    return CloneSymbol(defaultSymbol);
            }

            return CreateDefaultSymbol(type);
        }
Exemple #10
0
 internal override void BeginGeometry(GeometryType type)
 {
     if (_Builder==null)
     {
         Debug.Assert(_CurrentType.Count==0);
         _Builder=new GmlGeometryBuilder();
         _Builder.SetCoordinateSystem(CoordinateSystem);
     }
     _Builder.BeginGeometry(type);
     _CurrentType.Push(type);
 }
        public string GetFeatureClassFromMapping(string symbolSet, GeometryType geometryType)
        {
            foreach(SymbolSetMapping mapping in _symbolSetMappings)
            {
                if (mapping.SymbolSet == symbolSet && mapping.GeometryType == geometryType)
                {
                    return mapping.FeatureClassName;
                }
            }

            return "";
        }
Exemple #12
0
 public Vector2 CheckCollision(World world, GeometryType ignore)
 {
     float xMove = 0;
     GeometryBox collisionBox = new GeometryBox();
     collisionBox.rect = _bbox;
     if (world.Collides(_bbox, ignore, collisionBox, out collisionBox)) {
         xMove = 5 * Math.Sign(_bbox.X - collisionBox.rect.X);
     }
     _position += new Vector2(xMove, 0);
     _bbox.X += (int)xMove;
     return new Vector2(xMove, 0);
 }
 public virtual void GetSymbolResourceDictionaryEntriesAsync(GeometryType geometryType, object userState)
 {
     IEnumerable<SymbolResourceDictionaryEntry> dictEntries = null;
     try
     {
         dictEntries = GetSymbolResourceDictionaryEntries(geometryType);
     }
     catch (Exception ex)
     {
         OnGetResourceDictionariesFailed(new ExceptionEventArgs(ex, userState));
     }
     OnGetResourceDictionariesCompleted(new GetSymbolResourceDictionaryEntriesCompletedEventArgs() { SymbolResourceDictionaries = dictEntries, UserState = userState });
 }
Exemple #14
0
        protected virtual void WriteWkbType(GeometryType geometryType, Dimension dimension, int? srid)
        {
            uint dimensionType = 0;

            switch (dimension)
            {
                case Dimension.Xyz: dimensionType = 1000; break;
                case Dimension.Xym: dimensionType = 2000; break;
                case Dimension.Xyzm: dimensionType = 3000; break;
            }

            wkbWriter.Write(dimensionType + (uint)geometryType);
        }
        internal static void Populate(IGeometrySink sink, IList<SeriesNode> pointSeries, GeometryType type)
        {
            foreach (SeriesNode series in pointSeries)
            {
                if (type!=GeometryType.Polygon)
                    sink.BeginGeometry(GeometryType.LineString);

                List<PointNode> points=series.Select<ParseTreeNode, PointNode>(n => (PointNode)n.AstNode).ToList<PointNode>();
                MultiPointNode.Populate(sink, points, GeometryType.LineString);

                if (type!=GeometryType.Polygon)
                    sink.EndGeometry();
            }
        }
        public IEnumerable<SymbolResourceDictionaryEntry> GetSymbolResourceDictionaryEntries(GeometryType geometryType)
        {
            if(m_symbolResourceDictionaries == null)
                m_symbolResourceDictionaries = GetSymbolResourceDictionaryEntries();
            if (m_symbolResourceDictionaries == null)
                return null;

            List<SymbolResourceDictionaryEntry> list = new List<SymbolResourceDictionaryEntry>();            
            foreach (SymbolResourceDictionaryEntry entry in m_symbolResourceDictionaries)
            {                
                if (entry.GeometryType == geometryType || (entry.GeometryType == GeometryType.Point && geometryType == GeometryType.MultiPoint))
                    list.Add(entry);
            }
            return list;
        }
    /**
     * Constructor for GeometryInput
     * @param type - type signifies what object we are creating the input mapping for
     **/
    public GeometryInput(GeometryType type)
    {
        this.type = type;
        switch (type) {

        case GeometryType.CUBE:
            PopulateCube ();
            break;
        case GeometryType.ICOSPHERE:
            PopulateIcoSphere ();
            break;

        default:
            break;
        }
    }
Exemple #18
0
        protected virtual void WriteWktType(GeometryType geometryType, Dimension dimension, bool isEmpty)
        {
            wktBuilder.Append(geometryType.ToString().ToUpperInvariant());

            switch (dimension)
            {
                case Dimension.Xyz: wktBuilder.Append(" Z "); break;
                case Dimension.Xym: wktBuilder.Append(" M "); break;
                case Dimension.Xyzm: wktBuilder.Append(" ZM "); break;
            }

            if (isEmpty && dimension == Dimension.Xy)
                wktBuilder.Append(" ");

            if (isEmpty)
                wktBuilder.Append("EMPTY");
        }
        /// <summary>Starts the call sequence for the specified <see cref="GeometryType" />.</summary>
        /// <param name="type">The type of the geometry to build.</param>
        public override void BeginGeometry(GeometryType type)
        {
            if (_Geometry!=null)
            {
                _Geometry.BeginGeometry(type);
                return;
            }

            switch (type)
            {
            case GeometryType.GeometryCollection:
                _Geometry=new MultiGeometry();
                break;
            case GeometryType.LineString:
                _Geometry=new LineString();
                break;
            case GeometryType.MultiLineString:
                _Geometry=new MultiLineString();
                break;
            case GeometryType.MultiPoint:
                _Geometry=new MultiPoint();
                break;
            case GeometryType.MultiPolygon:
                _Geometry=new MultiPolygon();
                break;
            case GeometryType.Point:
                _Geometry=new Point();
                break;
            case GeometryType.Polygon:
                _Geometry=new Polygon();
                break;
            }

            if (_Geometry==null)
                throw new NotSupportedException(
                    string.Format(
                        CultureInfo.CurrentCulture,
                        SR.UnsupportedGeometryTypeException,
                        type
                    )
                );

            _Geometry.CoordinateSystem=TargetSystem;
        }
Exemple #20
0
        protected Geometry CreateGeometry(GeometryType geometryType, Dimension dimension)
        {
            Geometry geometry = null;

            switch (geometryType)
            {
                case GeometryType.Point: geometry = new Point(); break;
                case GeometryType.LineString: geometry = new LineString(); break;
                case GeometryType.Polygon: geometry = new Polygon(); break;
                case GeometryType.MultiPoint: geometry = new MultiPoint(); break;
                case GeometryType.MultiLineString: geometry = new MultiLineString(); break;
                case GeometryType.MultiPolygon: geometry = new MultiPolygon(); break;
                case GeometryType.GeometryCollection: geometry = new GeometryCollection(); break;
            }

            geometry.Dimension = dimension;

            return geometry;
        }
        private static IMultiParts ToGeneralMultiPart(MultiPartShapeBuffer multiPart, GeometryType geometryType)
        {
            IMultiParts multiParts;
            if (geometryType == GeometryType.Polyline)
            {
                multiParts = new GeometryFactory().CreatePolyline();
            }
            else
            {
                multiParts = new GeometryFactory().CreatePolygon();
            }

            var rings = multiParts.Parts;
            for (var i = 0; i < multiPart.NumParts; i++)
            {

                var partStart = multiPart.Parts[i];

                int partEnd;
                if (i + 1 < multiPart.NumParts)
                {
                    partEnd = multiPart.Parts[i + 1];
                }
                else
                {
                    partEnd = multiPart.NumPoints - 1;
                }

                var linearRing = new GeometryFactory().CreateLineString();
                var points = linearRing.Vertices;
                for (var j = partStart; j <= partEnd; j++)
                {
                    var mapPoint = new GeometryFactory().CreatePoint(multiPart.Points[i].x, multiPart.Points[i].y);

                    points.Add(mapPoint);
                }

                rings.Add(linearRing);
            }
            return multiParts;
        }
Exemple #22
0
        protected override void WriteWkbType(GeometryType geometryType, Dimension dimension, int? srid)
        {
            uint dimensionType = 0;

            switch (dimension)
            {
                case Dimension.Xyz: dimensionType = EwkbFlags.HasZ; break;
                case Dimension.Xym: dimensionType = EwkbFlags.HasM; break;
                case Dimension.Xyzm: dimensionType = EwkbFlags.HasZ | EwkbFlags.HasM; break;
            }

            if (srid.HasValue)
            {
                wkbWriter.Write(EwkbFlags.HasSrid + dimensionType + (uint)geometryType);
                wkbWriter.Write(srid.Value);
            }
            else
            {
                wkbWriter.Write(dimensionType + (uint)geometryType);
            }
        }
        //public GeometryAnnotation (List<CLLocation> points, GeometryType @type)
        public GeometryAnnotation(List<CLLocation> points, GeometryType @type)
        {
            Type = @type;
            Points = points;

            // create a unique ID for this route so it can be added to dictionaries by this key.
            RouteId = "";

            // determine a logical center point for this route based on the middle of the lat/lon extents.
            double maxLat = -91;
            double minLat =  91;
            double maxLon = -181;
            double minLon =  181;

            foreach (CLLocation currentLocation in Points)
            {
                CLLocationCoordinate2D coordinate = currentLocation.Coordinate;

                if(coordinate.Latitude > maxLat)
                    maxLat = coordinate.Latitude;
                if(coordinate.Latitude < minLat)
                    minLat = coordinate.Latitude;
                if(coordinate.Longitude > maxLon)
                    maxLon = coordinate.Longitude;
                if(coordinate.Longitude < minLon)
                    minLon = coordinate.Longitude;
            }

            _span.LatitudeDelta = (maxLat + 90) - (minLat + 90);
            _span.LongitudeDelta = (maxLon + 180) - (minLon + 180);

            CLLocationCoordinate2D _center = new CLLocationCoordinate2D();
            _center.Latitude = minLat + _span.LatitudeDelta / 2;
            _center.Longitude = minLon + _span.LongitudeDelta / 2;
            Coordinate = _center;

            LineColor = UIColor.Blue;
            System.Diagnostics.Debug.WriteLine("Found center of new Route Annotation at {0},{1}", Coordinate.Latitude, Coordinate.Longitude);
        }
Exemple #24
0
        public Vector2 MoveTo(Vector2 position, World world, out int hcol, out int vcol, GeometryType ignore)
        {
            Vector2 delta = position - _position;
            hcol = 0;
            vcol = 0;

            while (delta.LengthSquared() > 0.1f) {
                float dX = Math.Sign(delta.X);
                if (Math.Abs(delta.X) < 1) dX = delta.X;
                delta.X -= dX;

                float dY = Math.Sign(delta.Y);
                if (Math.Abs(delta.Y) < 1) dY = delta.Y;
                delta.Y -= dY;

                _bbox.X += (int)Math.Round(dX);
                if (world.Collides(_bbox, ignore)) {
                    _bbox.X -= (int)Math.Round(dX);
                    hcol = Math.Sign(dX);
                    delta.X = 0;
                    dX = 0;
                }

                _position.X += dX;

                _bbox.Y += (int)Math.Round(dY);

                if (world.Collides(_bbox, ignore)) {
                    _bbox.Y -= (int)Math.Round(dY);
                    vcol = Math.Sign(dY);
                    delta.Y = 0;
                    dY = 0;
                }

                _position.Y += dY;
            }

            return _position;
        }
Exemple #25
0
            public void BeginGeometry(GeometryType type)
            {
                if ((_Builder.Length>0) && (_Builder[_Builder.Length-1]==')'))
                    _Builder.Append(", ");

                if ((_CurrentType.Count==0) || (_CurrentType.Peek()==GeometryType.GeometryCollection))
                {
                    _Builder.Append(type.ToString("G").ToUpperInvariant());
                    _Builder.Append(" ");
                }

                _CurrentType.Push(type);

                switch (type)
                {
                case GeometryType.GeometryCollection:
                case GeometryType.MultiLineString:
                case GeometryType.MultiPoint:
                case GeometryType.MultiPolygon:
                case GeometryType.Polygon:
                    _Builder.Append("(");
                    break;
                }
            }
Exemple #26
0
 public static GeometryType GetTypemask(GeometryType typemask, GeometryType single, GeometryType plural)
 {
     if ((typemask & single) > 0)
     {
         typemask = typemask | plural;
     }
     else if (typemask == GeometryType.None)
     {
         typemask = typemask | single;
     }
     else
     {
         typemask = typemask | GeometryType.GeometryCollection;
     }
     return(typemask);
 }
Exemple #27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RenderEventArgs"/> class.
 /// </summary>
 /// <param name="renderMode">render mode.</param>
 /// <param name="viewport"></param>
 /// <param name="camera">camera used during rendering.</param>
 /// <param name="pickingGeometryType">Target geometry type(point, line, triangle, quad or polygon) for color-coded-picking when <paramref name="renderMode"/> is <see cref="RenderModes.ColorCodedPicking"/>; otherwise useless.</param>
 public RenderEventArgs(RenderModes renderMode, Rectangle viewport, ICamera camera, GeometryType pickingGeometryType = GeometryType.Point)
 {
     this.RenderMode          = renderMode;
     this.CanvasRect          = viewport;
     this.Camera              = camera;
     this.PickingGeometryType = pickingGeometryType;
 }
        private void onGetSymbolsForResourceDictionariesCompleted(GeometryType geometryType, SymbolResourceDictionaryEntry entry, GetSymbolsForResourceDictionaryCompletedEventArgs e2, object userState)
        {
            IEnumerable<SymbolDescription> symbols = e2.Symbols;
            if (symbols == null || symbols.Count() < 1)
            {
                base.OnGetDefaultSymbolFailed(new ExceptionEventArgs(string.Format(Resources.Strings.ExceptionNoDefaultSymbolsFoundInDictionaryForGeometryType, entry.DisplayName, geometryType), userState));
                return;
            }

            base.OnGetDefaultSymbolCompleted(new GetDefaultSymbolCompletedEventArgs() { DefaultSymbol = symbols.ElementAt(0), UserState = userState, GeometryType = geometryType });
        }
Exemple #29
0
 internal protected void BeginGeometry(GeometryType type)
 {
 }
Exemple #30
0
        public static GeometryOffsets BuildGeometry(FlatBufferBuilder builder, IGeometry geometry, GeometryType geometryType, byte dimensions)
        {
            var go = new GeometryOffsets();

            go.type = geometryType;

            if (geometry == null)
            {
                return(go);
            }

            if (geometryType == GeometryType.MultiLineString)
            {
                uint            end = 0;
                MultiLineString mls = (MultiLineString)geometry;
                if (mls.NumGeometries > 1)
                {
                    go.ends = new uint[mls.NumGeometries];
                    for (int i = 0; i < mls.NumGeometries; i++)
                    {
                        go.ends[i] = end += (uint)mls.Geometries[i].NumPoints;
                    }
                }
            }
            else if (geometryType == GeometryType.Polygon)
            {
                go.ends = CreateEnds(geometry as IPolygon, dimensions);
            }
            else if (geometryType == GeometryType.MultiPolygon)
            {
                MultiPolygon      mp            = (MultiPolygon)geometry;
                int               numGeometries = mp.NumGeometries;
                GeometryOffsets[] gos           = new GeometryOffsets[numGeometries];
                for (int i = 0; i < numGeometries; i++)
                {
                    Polygon p = (Polygon)mp.Geometries[i];
                    gos[i] = BuildGeometry(builder, p, GeometryType.Polygon, dimensions);
                }
                go.gos = gos;
                return(go);
            }

            var coordinates = geometry.Coordinates
                              .SelectMany(c => new double[] { c.X, c.Y })
                              .ToArray();

            go.coordsOffset = Geometry.CreateXyVector(builder, coordinates);

            if (go.ends != null)
            {
                go.endsOffset = Geometry.CreateEndsVector(builder, go.ends);
            }
            return(go);
        }
Exemple #31
0
 /// <summary>
 /// Pick geometry at specified positon.
 /// </summary>
 /// <param name="x">Left Down is (0, 0)</param>
 /// <param name="y">Left Down is (0, 0)</param>
 /// <param name="geometryType"></param>
 /// <param name="width"></param>
 /// <param name="height"></param>
 /// <returns></returns>
 public PickedGeometry Pick(int x, int y, GeometryType geometryType, int width, int height)
 {
     return(Pick(x, y, geometryType.ToFlags(), width, height));
 }
 public SubmeshBuilder(AddVertexDelegate addVertex, GeometryType geomType)
 {
     this.m_addVertex = addVertex;
     this.GeomType    = geomType;
 }
Exemple #33
0
 /// <summary>
 ///   Adds to a solver description object a vertex
 /// </summary>
 /// <param name = "solverObject"></param>
 /// <param name = "point"></param>
 /// <param name = "type"></param>
 /// <param name = "pointIndex"></param>
 private static void BuildSolverVertex(SolverGeometricObject solverObject, Point3D point, GeometryType type,
                                       int pointIndex)
 {
     AddVertexToSolver(solverObject, point, type, pointIndex);
 }
        private void getSymbolResourceDictionaryEntries(GeometryType geometryType, object userState, EventHandler<GetSymbolResourceDictionaryEntriesCompletedEventArgs> onCompleted, EventHandler<ExceptionEventArgs> onFailed)
        {
            WebClient wc = new WebClient();
            wc.DownloadStringCompleted += (o, e) =>
            {
                if (e.Error != null)
                {
                    onFailed(this, new ExceptionEventArgs(e.Error, userState));
                    return;
                }
                else if (string.IsNullOrEmpty(e.Result))
                {
                    onFailed(this, new ExceptionEventArgs(Resources.Strings.ExceptionConfigurationFileEmpty, userState));
                    return;
                }

                IEnumerable<SymbolResourceDictionaryEntry> entries = null;
                try
                {
                    entries = ParseResourceDictionaryEntriesFromXml(e.Result);
                }
                catch (Exception ex)
                {
                    onFailed(this, new ExceptionEventArgs(ex, userState));
                    return;
                }

                // Prefix each of the entries with symbol path
                foreach (SymbolResourceDictionaryEntry entry in entries)
                {
                    entry.Path = string.Format("{0}/{1}", SymbolFolderParentUrl, entry.Path);
                }
                m_symbolResourceDictionaries = entries;

                List<SymbolResourceDictionaryEntry> filteredEntries = new List<SymbolResourceDictionaryEntry>();
                foreach (SymbolResourceDictionaryEntry entry in m_symbolResourceDictionaries)
                {
                    if (entry.GeometryType == geometryType || (entry.GeometryType == GeometryType.Point && geometryType == GeometryType.MultiPoint))
                        filteredEntries.Add(entry);
                }

                onCompleted(this, new GetSymbolResourceDictionaryEntriesCompletedEventArgs()
                {
                    SymbolResourceDictionaries = filteredEntries,
                    UserState = e.UserState,
                });
            };
            wc.DownloadStringAsync(new Uri(ConfigFileUrl, UriKind.RelativeOrAbsolute), userState);
        }
        public async Task <List <MapPoint> > ToPointCollectionAsync(Geometry geometry)
        {
            List <MapPoint> result = null;

            PointNr = 0;

            if (geometry != null)
            {
                result = new List <MapPoint>();
                GeometryType geometryType = geometry.GeometryType;

                switch (geometryType)
                {
                case GeometryType.Point:
                    if ((!geometry.IsEmpty) && IsPointMeasurement)
                    {
                        if (geometry is MapPoint mapPoint)
                        {
                            result.Add(await AddZOffsetAsync(mapPoint));
                        }
                    }

                    break;

                case GeometryType.Polygon:
                case GeometryType.Polyline:

                    if (geometry is Multipart multipart)
                    {
                        ReadOnlyPointCollection points     = multipart.Points;
                        IEnumerator <MapPoint>  enumPoints = points.GetEnumerator();

                        while (enumPoints.MoveNext())
                        {
                            MapPoint mapPointPart = enumPoints.Current;
                            result.Add(await AddZOffsetAsync(mapPointPart));
                        }
                    }

                    break;
                }

                PointNr = result.Count;

                if ((PointNr >= 2) && (geometryType == GeometryType.Polygon))
                {
                    MapPoint point1 = result[0];
                    MapPoint point2 = result[PointNr - 1];
                    PointNr = point1.IsEqual(point2) ? (PointNr - 1) : PointNr;
                }

                if ((PointNr >= 2) && (geometryType == GeometryType.Polyline))
                {
                    MapPoint point1 = result[0];
                    MapPoint point2 = result[PointNr - 1];

                    if (point1.IsEqual(point2))
                    {
                        PointNr = PointNr - 1;
                        result.RemoveAt(result.Count - 1);
                    }
                }
            }

            return(result);
        }
Exemple #36
0
 public int GetUniqueCount(GeometryType geometryType)
 {
     return(_uniqueCounts[geometryType]);
 }
Exemple #37
0
 public int GetCount(GeometryType geometryType)
 {
     return(_counts[geometryType]);
 }
        private CanvasGeometry CreateGeometry(ICanvasResourceCreator resourceCreator, GeometryType type)
        {
            switch (type)
            {
            case GeometryType.Rectangle: return(CanvasGeometry.CreateRectangle(resourceCreator, 100, 100, 300, 350));

            case GeometryType.RoundedRectangle: return(CanvasGeometry.CreateRoundedRectangle(resourceCreator, 80, 80, 400, 400, 100, 100));

            case GeometryType.Ellipse: return(CanvasGeometry.CreateEllipse(resourceCreator, 275, 275, 225, 275));

            case GeometryType.Star:
            {
                return(Utils.CreateStarGeometry(resourceCreator, 250, new Vector2(250, 250)));
            }

            case GeometryType.Group:
            {
                CanvasGeometry geo0 = CanvasGeometry.CreateRectangle(resourceCreator, 100, 100, 100, 100);
                CanvasGeometry geo1 = CanvasGeometry.CreateRoundedRectangle(resourceCreator, 300, 100, 100, 100, 50, 50);

                CanvasPathBuilder pathBuilder = new CanvasPathBuilder(resourceCreator);
                pathBuilder.BeginFigure(200, 200);
                pathBuilder.AddLine(500, 200);
                pathBuilder.AddLine(200, 350);
                pathBuilder.EndFigure(CanvasFigureLoop.Closed);
                CanvasGeometry geo2 = CanvasGeometry.CreatePath(pathBuilder);

                return(CanvasGeometry.CreateGroup(resourceCreator, new CanvasGeometry[] { geo0, geo1, geo2 }));
            }
            }
            System.Diagnostics.Debug.Assert(false);
            return(null);
        }
 /// <summary>
 /// Constructor for the GeometryVision targeting instructions object
 /// </summary>
 /// <param name="geoType"></param>
 /// <param name="tagName"></param>
 /// <param name="targetingSystems">Item1 entity targeting system, Item2 GameObject targeting system</param>
 /// <param name="targetingEnabled"></param>
 /// <param name="entityQueryFilter"></param>
 public TargetingInstruction(GeometryType geoType, string tagName, (IGeoTargeting, IGeoTargeting) targetingSystems, bool targetingEnabled, Object entityQueryFilter)
        public override void CreateLayerAsync(Resource layerResource, SpatialReference mapSpatialReference, object userState)
        {
            if (layerResource.ResourceType == ResourceType.DatabaseTable)
            {
                featureService = new FeatureService(layerResource.Url);
                featureService.GetFeatureServiceDetailsFailed += (o, e) =>
                {
                    OnCreateLayerFailed(e);
                };
                featureService.GetFeatureServiceDetailsCompleted += (o, e) =>
                {
                    if (e.FeatureServiceInfo == null)
                    {
                        OnCreateLayerFailed(new ESRI.ArcGIS.Mapping.Core.ExceptionEventArgs(new Exception(Resources.Strings.ExceptionUnableToRetrieveLayerDetails), e.UserState));
                        return;
                    }
                    GeometryType GeometryType = GeometryType.Unknown;
                    switch (e.FeatureServiceInfo.GeometryType)
                    {
                    case "esriGeometryPoint":
                        GeometryType = GeometryType.Point;
                        break;

                    case "esriGeometryMultipoint":
                        GeometryType = GeometryType.MultiPoint;
                        break;

                    case "esriGeometryPolyline":
                        GeometryType = GeometryType.Polyline;
                        break;

                    case "esriGeometryPolygon":
                        GeometryType = GeometryType.Polygon;
                        break;
                    }
                    FeatureLayer newFeatureLayer = new FeatureLayer()
                    {
                        Url      = featureService.Uri,
                        ID       = Guid.NewGuid().ToString("N"),
                        Mode     = FeatureLayer.QueryMode.OnDemand,
                        Renderer = new ESRI.ArcGIS.Mapping.Core.Symbols.HiddenRenderer()
                    };
                    newFeatureLayer.SetValue(MapApplication.LayerNameProperty, layerResource.DisplayName);
                    newFeatureLayer.SetValue(Core.LayerExtensions.GeometryTypeProperty, GeometryType);
                    newFeatureLayer.SetValue(Core.LayerExtensions.DisplayUrlProperty, layerResource.Url);

                    if (e.FeatureServiceInfo.Fields != null)
                    {
                        Collection <FieldInfo> fields = new Collection <FieldInfo>();
                        foreach (Field field in e.FeatureServiceInfo.Fields)
                        {
                            if (field.DataType == "Microsoft.SqlServer.Types.SqlGeometry" || field.DataType == "esriFieldTypeGeometry")
                            {
                                continue;
                            }
                            fields.Add(new FieldInfo()
                            {
                                DisplayName = field.Name,
                                FieldType   = mapFieldType(field.DataType),
                                Name        = field.Name,
                                VisibleInAttributeDisplay = true,
                                VisibleOnMapTip           = true,
                            });
                        }
                        newFeatureLayer.SetValue(Core.LayerExtensions.FieldsProperty, fields);
                    }
                    newFeatureLayer.OutFields.Add("*"); // Get all fields at configuration time
                    OnCreateLayerCompleted(new CreateLayerCompletedEventArgs()
                    {
                        Layer = newFeatureLayer, UserState = e.UserState, GeometryType = GeometryType
                    });
                };
                featureService.GetFeatureServiceDetails(userState);
            }
            else
            {
                OnCreateLayerFailed(new ESRI.ArcGIS.Mapping.Core.ExceptionEventArgs(new Exception(string.Format(Resources.Strings.ExceptionCannotCreateLayerForResourceType, layerResource.ResourceType.ToString())), userState));
            }
        }
 public void BeginGeometry(GeometryType type)
 {
     _Builder.BeginGeometry(GeometryTypeUtils.ConvertToGeometry(type));
 }
Exemple #42
0
        public static async Task SerializeAsync(Stream output, IEnumerable <IFeature> features, GeometryType geometryType, byte dimensions = 2, IList <ColumnMeta> columns = null)
        {
            await output.WriteAsync(Constants.MagicBytes, 0, Constants.MagicBytes.Length);

            var headerBuffer = BuildHeader(0, geometryType, dimensions, columns, null);
            var bytes        = headerBuffer.ToSizedArray();
            await output.WriteAsync(bytes, 0, bytes.Length);

            headerBuffer.Position += 4;
            var header = Header.GetRootAsHeader(headerBuffer).UnPack();

            foreach (var feature in features)
            {
                var buffer = FeatureConversions.ToByteBuffer(feature, header);
                bytes = buffer.ToSizedArray();
                await output.WriteAsync(bytes, 0, bytes.Length);
            }
        }
        public string GetFeatureClassFromExtendedFunctionCode(string extendedFunctionCode, GeometryType geometryType)
        {
            if (string.IsNullOrEmpty(extendedFunctionCode))
            {
                return("Units");
            }

            var symbolSetMappings = SymbolSetMappings2525C;

            if (ProSymbolUtilities.Standard == ProSymbolUtilities.SupportedStandardsType.app6b)
            {
                symbolSetMappings = SymbolSetMappingsAPP6B;
            }

            foreach (SymbolSetMapping mapping in symbolSetMappings)
            {
                if (System.Text.RegularExpressions.Regex.IsMatch(extendedFunctionCode, mapping.SymbolSetOrRegex) &&
                    (mapping.GeometryType == geometryType))
                {
                    return(mapping.FeatureClassName);
                }
            }

            System.Diagnostics.Trace.WriteLine("GetFeatureClassFromExtendedFunctionCode - could not find feature class for: " + extendedFunctionCode);
            return("");
        }
Exemple #44
0
 void IGeometrySink.BeginGeometry(GeometryType type)
 {
     BeginGeometry(type);
 }
Exemple #45
0
        public static ArrayValue ReadArrayFromBuffer(ByteBuffer buffer)
        {
            if (buffer.limit() <= 0)
            {
                throw new System.InvalidOperationException("Given buffer is empty");
            }

            sbyte typeId = buffer.get();

            buffer.order(ByteOrder.BIG_ENDIAN);
            try
            {
                if (typeId == PropertyType.String.intValue())
                {
                    int      arrayLength = buffer.Int;
                    string[] result      = new string[arrayLength];

                    for (int i = 0; i < arrayLength; i++)
                    {
                        int byteLength = buffer.Int;
                        result[i] = UTF8.decode(buffer.array(), buffer.position(), byteLength);
                        buffer.position(buffer.position() + byteLength);
                    }
                    return(Values.stringArray(result));
                }
                else if (typeId == PropertyType.Geometry.intValue())
                {
                    GeometryType.GeometryHeader header = GeometryType.GeometryHeader.fromArrayHeaderByteBuffer(buffer);
                    sbyte[] byteArray = new sbyte[buffer.limit() - buffer.position()];
                    buffer.get(byteArray);
                    return(GeometryType.decodeGeometryArray(header, byteArray));
                }
                else if (typeId == PropertyType.Temporal.intValue())
                {
                    TemporalType.TemporalHeader header = TemporalType.TemporalHeader.fromArrayHeaderByteBuffer(buffer);
                    sbyte[] byteArray = new sbyte[buffer.limit() - buffer.position()];
                    buffer.get(byteArray);
                    return(TemporalType.decodeTemporalArray(header, byteArray));
                }
                else
                {
                    ShortArray type = ShortArray.typeOf(typeId);
                    int        bitsUsedInLastByte = buffer.get();
                    int        requiredBits       = buffer.get();
                    if (requiredBits == 0)
                    {
                        return(type.createEmptyArray());
                    }
                    if (type == ShortArray.Byte && requiredBits == (sizeof(sbyte) * 8))
                    {                              // Optimization for byte arrays (probably large ones)
                        sbyte[] byteArray = new sbyte[buffer.limit() - buffer.position()];
                        buffer.get(byteArray);
                        return(Values.byteArray(byteArray));
                    }
                    else
                    {                              // Fallback to the generic approach, which is a slower
                        Bits bits   = Bits.bitsFromBytes(buffer.array(), buffer.position());
                        int  length = ((buffer.limit() - buffer.position()) * 8 - (8 - bitsUsedInLastByte)) / requiredBits;
                        return(type.createArray(length, bits, requiredBits));
                    }
                }
            }
            finally
            {
                buffer.order(ByteOrder.LITTLE_ENDIAN);
            }
        }
Exemple #46
0
 public ShapeObject(GeometryType geometryType, object data)
 {
     Type = geometryType;
     Data = data;
 }
Exemple #47
0
 public static void Serialize(Stream output, IEnumerable <IFeature> features, GeometryType geometryType, byte dimensions = 2, IList <ColumnMeta> columns = null)
 {
     AsyncContext.Run(async() => await SerializeAsync(output, features, geometryType, dimensions, columns));
 }
Exemple #48
0
 protected Geometry(GeometryType type)
 {
     _type = type;
 }
        public string GetFeatureClassFromMapping(DisplayAttributes displayAttributes, GeometryType geometryType)
        {
            if (displayAttributes == null)
            {
                return(string.Empty);
            }

            if (ProSymbolUtilities.IsLegacyStandard())
            {
                return(GetFeatureClassFromExtendedFunctionCode(displayAttributes.ExtendedFunctionCode, geometryType));
            }
            else // 2525D or APPD
            {
                return(GetFeatureClassFromSymbolSet(displayAttributes.SymbolSet, geometryType));
            }
        }
Exemple #50
0
 public GRectangle(GeometryType type)
     : base(type)
 {
 }
        public override void GetDefaultSymbol(GeometryType geometryType, object userState)
        {
            #region Validation
            if (null == ConfigFileUrl)
            {
                base.OnGetDefaultSymbolFailed(new ExceptionEventArgs(Resources.Strings.ExceptionConfigFileUrlMustBeSpecified, userState));
                return;
            }

            if (null == SymbolFolderParentUrl)
            {
                base.OnGetDefaultSymbolFailed(new ExceptionEventArgs(Resources.Strings.ExceptionSymbolFolderParentUrlMustBeSpecified, userState));
                return;
            }
            #endregion

            if (geometryType == GeometryType.Unknown)
            {
                base.GetDefaultSymbol(geometryType, userState);
                return;
            }

            if (m_symbolResourceDictionaries == null)
            {
                getSymbolResourceDictionaryEntries(geometryType, userState, (o, e) =>
                {
                    if (e.SymbolResourceDictionaries == null || e.SymbolResourceDictionaries.Count() < 1)
                    {
                        base.OnGetDefaultSymbolFailed(new ExceptionEventArgs(string.Format(Resources.Strings.ExceptionNoResourceDictionaryfoundForGeometryType, geometryType), userState));
                        return;
                    }

                    SymbolResourceDictionaryEntry entry = e.SymbolResourceDictionaries.ElementAt(0);
                    getSymbolsForResourceDictionary(entry, userState, (o2, e2) =>
                    {
                        onGetSymbolsForResourceDictionariesCompleted(geometryType, entry, e2, userState);
                    }, (o2, e2) =>
                    {
                        base.OnGetDefaultSymbolFailed(e2);
                    });

                }, (o, e) =>
                {
                    base.OnGetDefaultSymbolFailed(e);
                });
            }
            else
            {
                // Find the one for the geometry type
                SymbolResourceDictionaryEntry entry = m_symbolResourceDictionaries.FirstOrDefault<SymbolResourceDictionaryEntry>(
                    e => e.GeometryType == geometryType
                    || (e.GeometryType == GeometryType.Point && geometryType == GeometryType.MultiPoint));
                if (entry == null)
                {
                    base.OnGetDefaultSymbolFailed(new ExceptionEventArgs(string.Format(Resources.Strings.ExceptionNoResourceDictionaryfoundForGeometryType, geometryType), userState));
                    return;
                }
                getSymbolsForResourceDictionary(entry, userState, (o2, e2) =>
                {
                    onGetSymbolsForResourceDictionariesCompleted(geometryType, entry, e2, userState);
                }, (o2, e2) =>
                {
                    base.OnGetDefaultSymbolFailed(e2);
                });
            }
        }
Exemple #52
0
 public GEllipse(GeometryType type)
     : base(type)
 {
 }
Exemple #53
0
 public void SetActiveGeometryType(GeometryType type, ZValueType zValue)
 {
     _layer.ActiveShapeType = GeometryHelper.GeometryType2ShpType(type, zValue);
 }
Exemple #54
0
 public static void AddGeometryType(FlatBufferBuilder builder, GeometryType geometryType)
 {
     builder.AddByte(2, (byte)geometryType, 0);
 }
Exemple #55
0
 public Geometry(GeometryType type)
 {
     Type = type;
 }
Exemple #56
0
 public GeometryRowStyle(GeometryStyle style, GeometryType type)
 {
     Style = style;
     Type  = type;
 }
 internal static ESRI.ArcGIS.Mapping.Core.GeometryType ToGeomType(GeometryType geomType)
 {
     switch (geomType)
     {
         case ESRI.ArcGIS.Client.Tasks.GeometryType.Point:
             return Core.GeometryType.Point;
         case ESRI.ArcGIS.Client.Tasks.GeometryType.MultiPoint:
             return Core.GeometryType.MultiPoint;
         case ESRI.ArcGIS.Client.Tasks.GeometryType.Polygon:
             return Core.GeometryType.Polygon;
         case ESRI.ArcGIS.Client.Tasks.GeometryType.Polyline:
             return Core.GeometryType.Polyline;
         case ESRI.ArcGIS.Client.Tasks.GeometryType.Envelope:
         default:
             return Core.GeometryType.Unknown;
     }
 }
Exemple #58
0
        private void PerformPostLayerInitializationActions(Layer layer, bool initializationSuccess)
        {
            GraphicsLayer gLayer = layer as GraphicsLayer;

            if (gLayer != null)
            {
                GeometryType           geometryType = Core.LayerExtensions.GetGeometryType(gLayer);
                Collection <FieldInfo> layerFields  = Core.LayerExtensions.GetFields(gLayer);
                FeatureLayer           featureLayer = layer as FeatureLayer;
                if (layerFields.Count == 0 &&
                    featureLayer != null && featureLayer.LayerInfo != null && featureLayer.LayerInfo.Fields != null)
                {
                    foreach (ESRI.ArcGIS.Client.Field field in featureLayer.LayerInfo.Fields)
                    {
                        if (FieldHelper.IsFieldFilteredOut(field.Type))
                        {
                            continue;
                        }
                        ESRI.ArcGIS.Mapping.Core.FieldInfo fieldInfo = ESRI.ArcGIS.Mapping.Core.FieldInfo.FieldInfoFromField(featureLayer, field);
                        layerFields.Add(fieldInfo);
                    }
                }
                if (gLayer.Graphics != null)
                {
                    #region Get geometry type, start getting symbology
                    if (geometryType == GeometryType.Unknown && gLayer.Graphics.Count > 0)
                    {
                        geometryType = LayerUtils.GetGeometryTypeFromGraphic(gLayer.Graphics.ElementAtOrDefault(0));
                        Core.LayerExtensions.SetGeometryType(gLayer, geometryType);

                        if ((gLayer.Renderer == null || gLayer.Renderer is HiddenRenderer) && !Symbology.DefaultSymbols.ContainsKey(geometryType))
                        {
                            if (geometryType == GeometryType.Unknown)
                            {
                                gLayer.SetValue(ESRI.ArcGIS.Client.Extensibility.LayerExtensions.ErrorMessageProperty, "Layer has unspecified geometry type.");
                            }
                            else
                            {
                                Core.LayerExtensions.SetRunLayerPostInitializationActions(gLayer, true);
                                SymbolConfigProvider.GetDefaultLinearGradientBrush(gLayer, ColorRampType.ClassBreaks);
                            }
                            return;
                        }
                    }
                    #endregion

                    #region Project graphics if necessary
                    if (graphicsRequireReprojection(gLayer.Graphics))
                    {
                        GeometryServiceOperationHelper helper = new GeometryServiceOperationHelper(
                            new ConfigurationStoreHelper().GetGeometryServiceUrl(ConfigurationStore)
                            );
                        helper.ProjectGraphicsCompleted += (sender, args) =>
                        {
                            GraphicsLayer targetLayer = args.UserState as GraphicsLayer;
                            if (targetLayer != null)
                            {
                                targetLayer.Graphics.Clear();
                                foreach (Graphic graphic in args.Graphics)
                                {
                                    targetLayer.Graphics.Add(graphic);
                                }
                            }
                        };
                        helper.ProjectGraphics(gLayer.Graphics, Map.SpatialReference, gLayer);
                    }
                    #endregion

                    #region Get field information
                    if (layerFields.Count == 0) // fields not determined yet
                    {
                        determineFieldsFromGraphic(layerFields, gLayer.Graphics.ElementAtOrDefault(0));
                    }
                    #endregion
                }

                #region Get renderer from feature layer's layer info, if necessary
                if (gLayer.Renderer == null || gLayer.Renderer is HiddenRenderer)
                {
                    FeatureLayer lay = gLayer as FeatureLayer;
                    if (lay != null && lay.LayerInfo != null && lay.LayerInfo.Renderer != null)
                    {
                        lay.Renderer = lay.LayerInfo.Renderer;
                    }
                }
                #endregion

                #region Change PictureMarkerSymbol to ImageFillSymbol
                if (gLayer.Renderer != null && (geometryType == GeometryType.Point || geometryType == GeometryType.MultiPoint))
                {
                    SimpleRenderer sr = gLayer.Renderer as SimpleRenderer;
                    ESRI.ArcGIS.Client.FeatureService.Symbols.PictureMarkerSymbol pms = null;
                    if (sr != null)
                    {
                        pms = sr.Symbol as ESRI.ArcGIS.Client.FeatureService.Symbols.PictureMarkerSymbol;
                        if (pms != null)
                        {
                            sr.Symbol = SymbolJsonHelper.ToImageFillSymbol(pms);
                        }
                    }
                    else
                    {
                        ClassBreaksRenderer cbr = gLayer.Renderer as ClassBreaksRenderer;
                        if (cbr != null)
                        {
                            foreach (ClassBreakInfo info in cbr.Classes)
                            {
                                pms = info.Symbol as ESRI.ArcGIS.Client.FeatureService.Symbols.PictureMarkerSymbol;
                                if (pms != null)
                                {
                                    info.Symbol = SymbolJsonHelper.ToImageFillSymbol(pms);
                                }
                            }
                        }
                        else
                        {
                            UniqueValueRenderer uvr = gLayer.Renderer as UniqueValueRenderer;
                            if (uvr != null)
                            {
                                foreach (UniqueValueInfo info in uvr.Infos)
                                {
                                    pms = info.Symbol as ESRI.ArcGIS.Client.FeatureService.Symbols.PictureMarkerSymbol;
                                    if (pms != null)
                                    {
                                        info.Symbol = SymbolJsonHelper.ToImageFillSymbol(pms);
                                    }
                                }
                            }
                        }
                    }
                }
                #endregion

                if (gLayer.Renderer == null || gLayer.Renderer is HiddenRenderer)
                {
                    ApplyDefaultRenderer(gLayer, geometryType);
                }

                ApplyDefaultGradientBrush(gLayer);
            }
            else if ((layer is ArcGISDynamicMapServiceLayer || layer is ArcGISTiledMapServiceLayer) &&
                     !((bool)layer.GetValue(ESRI.ArcGIS.Client.WebMap.Document.IsBaseMapProperty)))
            {
                //get layer infos - used later for figuring out domain/subtypes, etc
                if ((layer.GetValue(ESRI.ArcGIS.Mapping.Core.LayerExtensions.LayerInfosProperty) as Collection <LayerInformation>)
                    == null)
                {
                    getLayerInfos(layer);
                }
            }
            bool doSelect = false;
            layer.SetValue(ESRI.ArcGIS.Client.Extensibility.LayerExtensions.InitialUpdateCompletedProperty, true);
            if (!initializationSuccess)
            {
                layer.SetValue(ESRI.ArcGIS.Client.Extensibility.LayerExtensions.InitialUpdateFailedProperty, true);
            }
            else
            {
                bool hasId = !string.IsNullOrEmpty(layer.ID) || !string.IsNullOrEmpty(layer.GetValue(ESRI.ArcGIS.Client.Extensibility.MapApplication.LayerNameProperty) as  string);
                // Certain layers get added when the map draw mode is changed (An empty graphics layer is added)
                // We don't want to auto-select this layer
                if (hasId || !(layer is GraphicsLayer))
                {
                    doSelect = true;
                }
            }

            if (doSelect)
            {
                SetSelectedLayer(new LayerEventArgs()
                {
                    Layer = layer
                });
            }

            SubscribeToLayerInitializationEvents(layer, false);
        }
Exemple #59
0
 private static void AddVertexToSolver(SolverGeometricObject solverObject, Point3D point, GeometryType type,
                                       int pointIndex)
 {
     solverObject.Points.Add(new SolverDataPoint(point, type));
 }
Exemple #60
0
 private static IDiff Read(BinaryReader binaryReader, GeometryType geometryType, bool readZ)
 => Readers.TryGetValue(geometryType, out var reader)
         ? reader(binaryReader, readZ, 0)
         : throw new GeometryTypeException($"Geometry type not supported: {geometryType}");