コード例 #1
0
        /// <summary>
        /// Creates a new <c>FindOverlapsQuery</c> (and executes it). The result of the query
        /// can then be obtained through the <c>Result</c> property.
        /// </summary>
        /// <param name="index">The spatial index to search</param>
        /// <param name="closedShape">The closed shape defining the search area.</param>
        /// <param name="spatialType">The type of objects to look for.</param>
        internal FindOverlapsQuery(ISpatialIndex index, IPosition[] closedShape, SpatialType spatialType)
        {
            m_ClosedShape = new ClosedShape(closedShape);
            m_Points = new List<PointFeature>(100);
            m_Result = new List<ISpatialObject>(100);

            // If we are looking for points or lines, locate points that overlap. Note that
            // if the user does not actually want points in the result, we still do a point
            // search, since it helps with the selection of lines.
            if ((spatialType & SpatialType.Point)!=0 || (spatialType & SpatialType.Line)!=0)
            {
                index.QueryWindow(m_ClosedShape.Extent, SpatialType.Point, OnPointFound);

                // Remember the points in the result if the caller wants them
                if ((spatialType & SpatialType.Point)!=0)
                    m_Result.AddRange(m_Points.ToArray());
            }

            // Find lines (this automatically includes lines connected to the points we just found)
            if ((spatialType & SpatialType.Line)!=0)
                index.QueryWindow(m_ClosedShape.Extent, SpatialType.Line, OnLineFound);

            // Find any overlapping text
            if ((spatialType & SpatialType.Text)!=0)
                index.QueryWindow(m_ClosedShape.Extent, SpatialType.Text, OnTextFound);

            m_Result.TrimExcess();
            m_Points = null;
        }
コード例 #2
0
        internal EntityTranslationForm(string alias, SpatialType type)
        {
            InitializeComponent();

            m_Alias  = alias;
            m_Type   = type;
            m_Result = null;
        }
コード例 #3
0
        internal EntityTranslationForm(string alias, SpatialType type)
        {
            InitializeComponent();

            m_Alias = alias;
            m_Type = type;
            m_Result = null;
        }
コード例 #4
0
        private static IDictionary <String, Object> GetExpectedGeoJson(SpatialType type, params object[] members)
        {
            var json = new Dictionary <String, Object>();

            AddType(json, type);
            json.Add(type == SpatialType.Collection ? "geometries" : "coordinates", members);
            return(json);
        }
コード例 #5
0
 internal SpatialTreeBuilder <T> .SpatialBuilderNode CreateChildren(SpatialType type)
 {
     SpatialTreeBuilder <T> .SpatialBuilderNode item = new SpatialTreeBuilder <T> .SpatialBuilderNode {
         Parent = (SpatialTreeBuilder <T> .SpatialBuilderNode) this,
         Type   = type
     };
     this.Children.Add(item);
     return(item);
 }
コード例 #6
0
            /// <summary>
            /// Create a child node
            /// </summary>
            /// <param name="type">The node type</param>
            /// <returns>The child node</returns>
            internal SpatialBuilderNode CreateChildren(SpatialType type)
            {
                var node = new SpatialBuilderNode {
                    Parent = this, Type = type
                };

                this.Children.Add(node);
                return(node);
            }
コード例 #7
0
        private static Geometry EmptyGeometry(SpatialType type)
        {
            var b = new GeometryBuilderImplementation(implementation);

            b.SetCoordinateSystem(CoordinateSystem.DefaultGeometry);
            b.BeginGeometry(type);
            b.EndGeometry();

            return(b.ConstructedGeometry);
        }
コード例 #8
0
            /// <summary>
            /// Translates the coordinates member value of a MultiPoint, MultiLineString, or MultiPolygon object into method calls on the spatial pipeline.
            /// </summary>
            /// <param name="containedSpatialType">Type of the shape contained in the Multi shape.</param>
            /// <param name="coordinates">Parsed coordinates array.</param>
            private void SendMultiShape(SpatialType containedSpatialType, IEnumerable coordinates)
            {
                Debug.Assert(
                    containedSpatialType == SpatialType.Point ||
                    containedSpatialType == SpatialType.LineString ||
                    containedSpatialType == SpatialType.Polygon,
                    "SendMultiShape only expects to write Point, LineString, or Polygon contained shapes.");

                SendArrayOfArray(coordinates, (containedShapeCoordinates) => this.SendShape(containedSpatialType, containedShapeCoordinates));
            }
コード例 #9
0
 protected override SpatialType OnBeginGeometry(SpatialType shape)
 {
     if ((this.depth > 0) && this.processingGeography)
     {
         throw new FormatException(Strings.Validator_UnexpectedGeography);
     }
     this.processingGeography = false;
     this.BeginShape(shape);
     return(shape);
 }
コード例 #10
0
        /// <summary>
        /// Begin Geo
        /// </summary>
        /// <param name="type">The spatial type</param>
        protected virtual void BeginGeo(SpatialType type)
        {
            // close on nesting types until we find a container suitable for the current type
            while (!this.CanContain(type))
            {
                this.EndGeo();
            }

            this.containers.Push(type);
        }
コード例 #11
0
        /// <summary>
        /// End Geography/Geometry
        /// </summary>
        private void EndGeo()
        {
            SpatialType type = this.parentStack.Pop();

            switch (type)
            {
            case SpatialType.MultiPoint:
            case SpatialType.MultiLineString:
            case SpatialType.MultiPolygon:
            case SpatialType.Collection:
                if (!this.shouldWriteContainerWrapper)
                {
                    // container wrapper has been written, end it
                    this.writer.WriteEndElement();
                }

                this.writer.WriteEndElement();

                // On EndGeo we should turn off wrapper, nested empty collection types relies on this call.
                this.shouldWriteContainerWrapper = false;
                break;

            case SpatialType.Point:
                if (!figureWritten)
                {
                    // empty point needs an empty pos
                    this.WriteStartElement(GmlConstants.Position);
                    this.writer.WriteEndElement();
                }

                this.writer.WriteEndElement();
                break;

            case SpatialType.LineString:
                if (!figureWritten)
                {
                    // empty linestring needs an empty posList
                    this.WriteStartElement(GmlConstants.PositionList);
                    this.writer.WriteEndElement();
                }

                this.writer.WriteEndElement();
                break;

            case SpatialType.Polygon:
            case SpatialType.FullGlobe:
                this.writer.WriteEndElement();
                break;

            default:
                Debug.Assert(false, "Unknown type in stack, mismatch switch between BeginGeo() and EndGeo()?");
                break;
            }
        }
コード例 #12
0
ファイル: NtxImport.cs プロジェクト: 15831944/backsight
        private IEntity GetEntityType(Ntx.Feature f, SpatialType type)
        {
            if (m_Translator == null)
            {
                return(null);
            }

            string fc = f.FeatureCode;

            return(m_Translator.FindEntityTypeByExternalName(fc, type));
        }
コード例 #13
0
        internal GetEntityForm(ILayer layer, SpatialType t, int defaultEntityId)
        {
            if (layer==null)
                throw new ArgumentNullException("Map layer must be specified");

            InitializeComponent();

            m_Layer = layer;
            m_Type = t;
            m_SelectedEntity = null;
            m_DefaultEntityId = defaultEntityId;
        }
コード例 #14
0
ファイル: DrawQuery.cs プロジェクト: steve-stanton/backsight
 /// <summary>
 /// Creates a new <c>DrawQuery</c> that refers to the specified feature type(s),
 /// drawing the results of the spatial query to the specified display.
 /// </summary>
 /// <param name="index">The index to query</param>
 /// <param name="display">The display to draw to</param>
 /// <param name="style">The drawing style</param>
 /// <param name="types">The type(s) of spatial feature to draw</param>
 public DrawQuery(ISpatialIndex index, ISpatialDisplay display, IDrawStyle style, SpatialType types)
 {
     m_Display = display;
     m_Style = style;
     m_DoPaint = false;
     Timer t = new Timer(500);
     t.Elapsed += new ElapsedEventHandler(Timer_Elapsed);
     t.Start();
     index.QueryWindow(m_Display.Extent, types, OnQueryHit);
     t.Close();
     display.PaintNow();
 }
        private Geography CreateGeography <T>(SpatialType type, T data, Action <GeographyPipeline, T> writer)
        {
            var builder = SpatialImplementation.CurrentImplementation.CreateBuilder();

            builder.GeographyPipeline.SetCoordinateSystem(CoordinateSystem.DefaultGeography);

            builder.GeographyPipeline.BeginGeography(type);
            writer(builder.GeographyPipeline, data);
            builder.GeographyPipeline.EndGeography();

            return(builder.ConstructedGeography);
        }
コード例 #16
0
        public override void Select(ISpatialDisplay display, IPosition p, SpatialType spatialType)
        {
            ISpatialObject so = SelectObject(display, p, spatialType);

            if (so != null)
            {
                SetSelection(new Selection(so, p));
            }
            else
            {
                SetSelection(null);
            }
        }
コード例 #17
0
        public virtual void Select(ISpatialDisplay display, IPosition p, SpatialType spatialType)
        {
            if (m_Data == null)
            {
                return;
            }

            // Use a tolerance of 2mm at the map scale of the supplied display
            ILength size = new Length(0.002 * display.MapScale);

            ISpatialObject so = m_Data.QueryClosest(p, size, spatialType);

            SetSelection(new SpatialSelection(so));
        }
コード例 #18
0
ファイル: GmlReaderTests.cs プロジェクト: zhonli/odata.net
        private static XmlReader ExpectedEmptyGml(SpatialType type, CoordinateSystem coordinateSystem)
        {
            StringBuilder payloadBuilder = new StringBuilder();

            switch (type)
            {
            case SpatialType.Point:
                payloadBuilder.Append(GmlShapeElement("Point", coordinateSystem.EpsgId));
                payloadBuilder.Append(GmlElement("pos"));
                payloadBuilder.Append(GmlEndElement("pos"));
                payloadBuilder.Append(GmlEndElement("Point"));
                break;

            case SpatialType.LineString:
                payloadBuilder.Append(GmlShapeElement("LineString", coordinateSystem.EpsgId));
                payloadBuilder.Append(GmlElement("posList"));
                payloadBuilder.Append(GmlEndElement("posList"));
                payloadBuilder.Append(GmlEndElement("LineString"));
                break;

            case SpatialType.Polygon:
            case SpatialType.MultiPoint:
                payloadBuilder.Append(GmlShapeElement(type.ToString(), coordinateSystem.EpsgId));
                payloadBuilder.Append(GmlEndElement(type.ToString()));
                break;

            case SpatialType.MultiLineString:
                payloadBuilder.Append(GmlShapeElement("MultiCurve", coordinateSystem.EpsgId));
                payloadBuilder.Append(GmlEndElement("MultiCurve"));
                break;

            case SpatialType.MultiPolygon:
                payloadBuilder.Append(GmlShapeElement("MultiSurface", coordinateSystem.EpsgId));
                payloadBuilder.Append(GmlEndElement("MultiSurface"));
                break;

            case SpatialType.Collection:
                payloadBuilder.Append(GmlShapeElement("MultiGeometry", coordinateSystem.EpsgId));
                payloadBuilder.Append(GmlEndElement("MultiGeometry"));
                break;

            default:
                Assert.True(false, "unknown spatial type");
                break;
            }

            XElement xel = XElement.Parse(payloadBuilder.ToString());

            return(xel.CreateReader());
        }
コード例 #19
0
        internal GetEntityForm(ILayer layer, SpatialType t, int defaultEntityId)
        {
            if (layer == null)
            {
                throw new ArgumentNullException("Map layer must be specified");
            }

            InitializeComponent();

            m_Layer           = layer;
            m_Type            = t;
            m_SelectedEntity  = null;
            m_DefaultEntityId = defaultEntityId;
        }
コード例 #20
0
 internal override void BeginGeo(SpatialType type)
 {
     if (this.currentNode == null)
     {
         SpatialBuilderNode node = new SpatialBuilderNode {
             Type = type
         };
         this.currentNode         = node;
         this.lastConstructedNode = null;
     }
     else
     {
         this.currentNode = this.currentNode.CreateChildren(type);
     }
 }
コード例 #21
0
        private static string GetDataName(SpatialType type)
        {
            switch (type)
            {
            case SpatialType.Point:
            case SpatialType.LineString:
            case SpatialType.Polygon:
            case SpatialType.MultiPoint:
            case SpatialType.MultiLineString:
            case SpatialType.MultiPolygon:
                return("coordinates");

            case SpatialType.Collection:
                return("geometries");
            }
            throw new NotImplementedException();
        }
コード例 #22
0
ファイル: SelectionTool.cs プロジェクト: 15831944/backsight
        /// <summary>
        /// Selects stuff within the current limit line. This makes a private selection
        /// over and above any previous selection.
        /// </summary>
        void SelectLimit()
        {
            // Nothing to do if there is no limit line.
            if (m_Limit == null)
            {
                return;
            }

            // Empty out the current limit selection.
            m_LimSel.Clear();

            // Nothing to do if there's only one position.
            if (m_Limit.Count <= 1)
            {
                return;
            }

            // If we have just 2 positions, select everything that
            // intersects the line. Otherwise select inside the shape.

            try
            {
                // Close the limit line.
                m_Limit.Add(m_Limit[0]);

                // Select only lines if the limit line consists of only 2 points (otherwise select
                // whatever is currently visible on the active display)
                SpatialType types = (m_Limit.Count == 2 ? SpatialType.Line : m_Controller.VisibleFeatureTypes);

                // Make the selection.
                ISpatialIndex         index = CadastralMapModel.Current.Index;
                List <ISpatialObject> res   = new FindOverlapsQuery(index, m_Limit.ToArray(), types).Result;
                m_LimSel.AddRange(res);
            }

            catch
            {
            }

            finally
            {
                // Remove the closing point.
                int lastIndex = m_Limit.Count - 1;
                m_Limit.RemoveAt(lastIndex);
            }
        }
コード例 #23
0
 private void BeginShape(SpatialType type, CoordinateSystem defaultCoordinateSystem)
 {
     if (this.currentCoordinateSystem == null)
     {
         this.currentCoordinateSystem = defaultCoordinateSystem;
     }
     if (this.ShapeHasObjectScope)
     {
         this.WriteShapeHeader(type);
     }
     if (TypeHasArrayScope(type))
     {
         this.StartArrayScope();
     }
     this.stack.Push(type);
     this.figureDrawn = false;
 }
コード例 #24
0
ファイル: GeoJsonWriterBase.cs プロジェクト: nickchal/pash
 private void BeginShape(SpatialType type, CoordinateSystem defaultCoordinateSystem)
 {
     if (this.currentCoordinateSystem == null)
     {
         this.currentCoordinateSystem = defaultCoordinateSystem;
     }
     if (this.ShapeHasObjectScope)
     {
         this.WriteShapeHeader(type);
     }
     if (TypeHasArrayScope(type))
     {
         this.StartArrayScope();
     }
     this.stack.Push(type);
     this.figureDrawn = false;
 }
コード例 #25
0
 private void ParseMultiGeoText(SpatialType innerType, Action innerReader)
 {
     if (!this.ReadEmptySet())
     {
         this.ReadToken(WellKnownTextTokenType.LeftParen, null);
         this.pipeline.BeginGeo(innerType);
         innerReader();
         this.pipeline.EndGeo();
         while (this.ReadOptionalToken(WellKnownTextTokenType.Comma, null))
         {
             this.pipeline.BeginGeo(innerType);
             innerReader();
             this.pipeline.EndGeo();
         }
         this.ReadToken(WellKnownTextTokenType.RightParen, null);
     }
 }
コード例 #26
0
ファイル: GeoJsonWriterBase.cs プロジェクト: nickchal/pash
        private static string GetDataName(SpatialType type)
        {
            switch (type)
            {
                case SpatialType.Point:
                case SpatialType.LineString:
                case SpatialType.Polygon:
                case SpatialType.MultiPoint:
                case SpatialType.MultiLineString:
                case SpatialType.MultiPolygon:
                    return "coordinates";

                case SpatialType.Collection:
                    return "geometries";
            }
            throw new NotImplementedException();
        }
コード例 #27
0
        /// <summary>
        /// write tagged text for type
        /// </summary>
        /// <param name="type">the spatial type</param>
        private void WriteTaggedText(SpatialType type)
        {
            switch (type)
            {
            case SpatialType.Point:
                this.writer.Write(WellKnownTextConstants.WktPoint);
                break;

            case SpatialType.LineString:
                this.writer.Write(WellKnownTextConstants.WktLineString);
                break;

            case SpatialType.Polygon:
                this.writer.Write(WellKnownTextConstants.WktPolygon);
                break;

            case SpatialType.Collection:
                this.shapeWritten = false;
                this.writer.Write(WellKnownTextConstants.WktCollection);
                break;

            case SpatialType.MultiPoint:
                this.shapeWritten = false;
                this.writer.Write(WellKnownTextConstants.WktMultiPoint);
                break;

            case SpatialType.MultiLineString:
                this.shapeWritten = false;
                this.writer.Write(WellKnownTextConstants.WktMultiLineString);
                break;

            case SpatialType.MultiPolygon:
                this.shapeWritten = false;
                this.writer.Write(WellKnownTextConstants.WktMultiPolygon);
                break;

            case SpatialType.FullGlobe:
                this.writer.Write(WellKnownTextConstants.WktFullGlobe);
                break;
            }

            if (type != SpatialType.FullGlobe)
            {
                this.writer.Write(WellKnownTextConstants.WktWhitespace);
            }
        }
コード例 #28
0
            /// <summary>
            /// Translates the coordinates member value into method calls on the spatial pipeline.
            /// </summary>
            /// <param name="spatialType">SpatialType of the GeoJSON object.</param>
            /// <param name="contentMembers">Coordinates value of the GeoJSON object, or inner geometries for collection</param>
            private void SendCoordinates(SpatialType spatialType, IEnumerable contentMembers)
            {
                if (EnumerableAny(contentMembers))
                {
                    // non-empty shape
                    switch (spatialType)
                    {
                    case SpatialType.Point:
                        SendPoint(contentMembers);
                        break;

                    case SpatialType.LineString:
                        SendLineString(contentMembers);
                        break;

                    case SpatialType.Polygon:
                        SendPolygon(contentMembers);
                        break;

                    case SpatialType.MultiPoint:
                        SendMultiShape(SpatialType.Point, contentMembers);
                        break;

                    case SpatialType.MultiLineString:
                        SendMultiShape(SpatialType.LineString, contentMembers);
                        break;

                    case SpatialType.MultiPolygon:
                        SendMultiShape(SpatialType.Polygon, contentMembers);
                        break;

                    case SpatialType.Collection:
                        foreach (IDictionary <string, object> collectionMember in contentMembers)
                        {
                            SendToPipeline(collectionMember, false);
                        }

                        break;

                    default:
                        Debug.Assert(false, "SendCoordinates has not been implemented for SpatialType " + spatialType);
                        break;
                    }
                }
            }
コード例 #29
0
        private void WriteTaggedText(SpatialType type)
        {
            switch (type)
            {
            case SpatialType.Point:
                this.writer.Write("POINT");
                break;

            case SpatialType.LineString:
                this.writer.Write("LINESTRING");
                break;

            case SpatialType.Polygon:
                this.writer.Write("POLYGON");
                break;

            case SpatialType.MultiPoint:
                this.shapeWritten = false;
                this.writer.Write("MULTIPOINT");
                break;

            case SpatialType.MultiLineString:
                this.shapeWritten = false;
                this.writer.Write("MULTILINESTRING");
                break;

            case SpatialType.MultiPolygon:
                this.shapeWritten = false;
                this.writer.Write("MULTIPOLYGON");
                break;

            case SpatialType.Collection:
                this.shapeWritten = false;
                this.writer.Write("GEOMETRYCOLLECTION");
                break;

            case SpatialType.FullGlobe:
                this.writer.Write("FULLGLOBE");
                break;
            }
            if (type != SpatialType.FullGlobe)
            {
                this.writer.Write(" ");
            }
        }
コード例 #30
0
            private void BeginShape(SpatialType type)
            {
                this.depth++;
                switch (type)
                {
                case SpatialType.Point:
                    this.Execute(PipelineCall.BeginPoint);
                    return;

                case SpatialType.LineString:
                    this.Execute(PipelineCall.BeginLineString);
                    return;

                case SpatialType.Polygon:
                    this.Execute(PipelineCall.BeginPolygon);
                    return;

                case SpatialType.MultiPoint:
                    this.Execute(PipelineCall.BeginMultiPoint);
                    return;

                case SpatialType.MultiLineString:
                    this.Execute(PipelineCall.BeginMultiLineString);
                    return;

                case SpatialType.MultiPolygon:
                    this.Execute(PipelineCall.BeginMultiPolygon);
                    return;

                case SpatialType.Collection:
                    this.Execute(PipelineCall.BeginCollection);
                    return;

                case SpatialType.FullGlobe:
                    if (!this.processingGeography)
                    {
                        throw new FormatException(Strings.Validator_InvalidType(type));
                    }
                    this.Execute(PipelineCall.BeginFullGlobe);
                    return;
                }
                throw new FormatException(Strings.Validator_InvalidType(type));
            }
コード例 #31
0
 private void BeginGeo(SpatialType type)
 {
     SpatialType type2 = (this.parentStack.Count == 0) ? SpatialType.Unknown : this.parentStack.Peek();
     switch (type2)
     {
         case SpatialType.MultiPoint:
         case SpatialType.MultiLineString:
         case SpatialType.MultiPolygon:
         case SpatialType.Collection:
             this.writer.Write(this.shapeWritten ? ", " : "(");
             break;
     }
     if ((type2 == SpatialType.Unknown) || (type2 == SpatialType.Collection))
     {
         this.WriteTaggedText(type);
     }
     this.figureWritten = false;
     this.parentStack.Push(type);
 }
コード例 #32
0
        /// <summary>
        /// Begin a new spatial type
        /// </summary>
        /// <param name="type">The spatial type</param>
        internal override void BeginGeo(SpatialType type)
        {
            Debug.Assert(type != SpatialType.Unknown, "cannot build unknown type - should have validated this call");

            // traverse down the tree);
            if (this.currentNode == null)
            {
                this.currentNode = new SpatialBuilderNode {
                    Type = type
                };

                // we are just getting started, clear the last built
                this.lastConstructedNode = null;
            }
            else
            {
                this.currentNode = this.currentNode.CreateChildren(type);
            }
        }
コード例 #33
0
            private void SendCoordinates(SpatialType spatialType, IEnumerable contentMembers)
            {
                if (EnumerableAny(contentMembers))
                {
                    switch (spatialType)
                    {
                    case SpatialType.Point:
                        this.SendPoint(contentMembers);
                        return;

                    case SpatialType.LineString:
                        this.SendLineString(contentMembers);
                        return;

                    case SpatialType.Polygon:
                        this.SendPolygon(contentMembers);
                        return;

                    case SpatialType.MultiPoint:
                        this.SendMultiShape(SpatialType.Point, contentMembers);
                        return;

                    case SpatialType.MultiLineString:
                        this.SendMultiShape(SpatialType.LineString, contentMembers);
                        return;

                    case SpatialType.MultiPolygon:
                        this.SendMultiShape(SpatialType.Polygon, contentMembers);
                        return;

                    case SpatialType.Collection:
                        foreach (IDictionary <string, object> dictionary in contentMembers)
                        {
                            this.SendToPipeline(dictionary, false);
                        }
                        break;

                    default:
                        return;
                    }
                }
            }
コード例 #34
0
        /// <summary>
        /// Start to write a new Geography/Geometry
        /// </summary>
        /// <param name="type">The SpatialType to write</param>
        private void BeginGeo(SpatialType type)
        {
            SpatialType parentType = this.parentStack.Count == 0 ? SpatialType.Unknown : this.parentStack.Peek();

            if (parentType == SpatialType.MultiPoint || parentType == SpatialType.MultiLineString || parentType == SpatialType.MultiPolygon || parentType == SpatialType.Collection)
            {
                // container, first element should write out (, subsequent ones write out ","
                this.writer.Write(this.shapeWritten ? WellKnownTextConstants.WktDelimiterWithWhiteSpace : WellKnownTextConstants.WktOpenParen);
            }

            // Write tagged text
            // Only write if toplevel, or the parent is a collection type
            if (parentType == SpatialType.Unknown || parentType == SpatialType.Collection)
            {
                this.WriteTaggedText(type);
            }

            this.figureWritten = false;
            this.parentStack.Push(type);
        }
コード例 #35
0
        private void BeginGeo(SpatialType type)
        {
            SpatialType type2 = (this.parentStack.Count == 0) ? SpatialType.Unknown : this.parentStack.Peek();

            switch (type2)
            {
            case SpatialType.MultiPoint:
            case SpatialType.MultiLineString:
            case SpatialType.MultiPolygon:
            case SpatialType.Collection:
                this.writer.Write(this.shapeWritten ? ", " : "(");
                break;
            }
            if ((type2 == SpatialType.Unknown) || (type2 == SpatialType.Collection))
            {
                this.WriteTaggedText(type);
            }
            this.figureWritten = false;
            this.parentStack.Push(type);
        }
コード例 #36
0
        /// <summary>
        /// The schemas that relate to the specified spatial type and mapping layer.
        /// </summary>
        /// <param name="t">The type(s) of interest</param>
        /// <param name="layer">The layer of interest (null for all layers)</param>
        /// <returns>The schemas associated with the entity types that apply to the specified
        /// spatial type and mapping layer</returns>
        public static ITable[] Schemas(SpatialType t, ILayer layer)
        {
            List <ITable> result = new List <ITable>();

            IEntity[] ents = EntityTypes(t, layer);

            foreach (IEntity e in ents)
            {
                ITable[] entSchemas = e.DefaultTables;
                foreach (ITable schema in entSchemas)
                {
                    if (!result.Contains(schema))
                    {
                        result.Add(schema);
                    }
                }
            }

            return(result.ToArray());
        }
コード例 #37
0
        /// <summary>
        /// Gets the name of the GeoJson member to use when writing the body of the spatial object.
        /// </summary>
        /// <param name="type">SpatialType being written.</param>
        /// <returns>Name of the GeoJson member to use when writing the body of the spatial object.</returns>
        private static string GetDataName(SpatialType type)
        {
            switch (type)
            {
            case SpatialType.Point:
            case SpatialType.LineString:
            case SpatialType.Polygon:
            case SpatialType.MultiPoint:
            case SpatialType.MultiLineString:
            case SpatialType.MultiPolygon:
                return(GeoJsonConstants.CoordinatesMemberName);

            case SpatialType.Collection:
                return(GeoJsonConstants.GeometriesMemberName);

            default:
                Debug.Assert(false, "SpatialType " + type + " is not currently supported in GeoJsonWriter.");
                throw new NotImplementedException();
            }
        }
コード例 #38
0
        /// <summary>
        /// Creates a new <c>FindClosestQuery</c> (and executes it). The result of the query
        /// can then be obtained through the <c>Result</c> property.
        /// </summary>
        /// <param name="index">The spatial index to search</param>
        /// <param name="p">The search position.</param>
        /// <param name="radius">The search tolerance (expected to be greater than zero).</param>
        /// <param name="types">The type of objects to look for.</param>
        internal FindClosestQuery(ISpatialIndex index, IPosition p, ILength radius, SpatialType types)
        {
            if (types==0)
                throw new ArgumentNullException("Spatial type(s) not specified");

            // If the user hasn't been specific, ensure we don't search for polygons!
            SpatialType useTypes = (types==SpatialType.All ? SpatialType.Feature : types);
            Debug.Assert((useTypes & SpatialType.Polygon)==0);

            // It's important to round off to the nearest micron. Otherwise you might not
            // get the desired results in situations where the search radius is zero.
            m_Position = PositionGeometry.Create(p);

            m_Radius = radius;
            m_Types = types;
            m_Result = null;
            m_Distance = m_Radius.Meters;

            // The query will actually involve a square window, not a circle.
            IWindow x = new Window(m_Position, radius.Meters * 2.0);
            index.QueryWindow(x, useTypes, OnQueryHit);
        }
コード例 #39
0
        public IEntity FindEntityTypeByExternalName(string alias, SpatialType type)
        {
            IEntity result = (m_Translator==null ? null : m_Translator.Translate(alias));
            if (result!=null)
                return result;

            // Ask the user to pick a suitable translation
            EntityTranslationForm dial = new EntityTranslationForm(alias, type);
            dial.ShowDialog();
            result = dial.Result;
            dial.Dispose();

            // Remember what was specified
            if (result!=null)
            {
                if (m_Translator==null)
                    m_Translator = new TranslationFile();

                m_Translator.Add(alias, result);
            }

            return result;
        }
コード例 #40
0
        private static string GetGeoJsonTypeName(SpatialType spatialType)
        {
            if(spatialType == SpatialType.Collection)
            {
                return "GeometryCollection";
            }

            return Enum.GetName(spatialType.GetType(), spatialType);
        }
コード例 #41
0
        private static IDictionary<string, object> GetJsonMembers(SpatialType spatialType, IEnumerable<object> coordinates, IDictionary<string, object> crs)
        {
            var members = new Dictionary<string, object>();

            members.Add(GeoJsonConstants.TypeMemberName, GetGeoJsonTypeName(spatialType));

            if (coordinates != null)
            {
                members.Add(GeoJsonConstants.CoordinatesMemberName, coordinates);
            }

            if (crs != null)
            {
                members.Add(GeoJsonConstants.CrsMemberName, crs);
            }
            return members;
        }
コード例 #42
0
ファイル: MainForm.cs プロジェクト: steve-stanton/backsight
        void SetDefaultEntity(SpatialType t)
        {
            ILayer layer = ActiveLayer;
            if (layer==null)
                return;

            IEntity e = CadastralMapModel.Current.GetDefaultEntity(t);
            int entId = (e == null ? 0 : e.Id);
            GetEntityForm dial = new GetEntityForm(layer, t, entId);
            if (dial.ShowDialog() == DialogResult.OK)
            {
                e = dial.SelectedEntity;
                CadastralMapModel.Current.SetDefaultEntity(t, e);
            }
            dial.Dispose();
        }
コード例 #43
0
 private static void TestSendToPipeline(SpatialType spatialType, List<object> coordinates, Func<List<object>, bool, ICommonLoggingPipeline> getExpectedPipeline)
 {
     // Test with both Geography and Geometry pipelines
     TestSendToPipeline(spatialType, coordinates, true, getExpectedPipeline);
     TestSendToPipeline(spatialType, coordinates, false, getExpectedPipeline);
 }
コード例 #44
0
 public override void BeginGeography(SpatialType type)
 {
     logger.BeginShape(PipelineMethod.BeginGeography, type);
 }
コード例 #45
0
 private static void TestErrorOnUnexpectedNumeric(SpatialType spatialType, List<object> coordinates)
 {
     SpatialTestUtils.VerifyExceptionThrown<ParseErrorException>(() =>
                                                             ExecuteSendToPipeline(spatialType, coordinates),
                                                             Strings.GeoJsonReader_ExpectedArray);
 }
コード例 #46
0
 public void BeginShape(SpatialType spatialType)
 {
     this.drawGeography.BeginGeography(spatialType);
 }
コード例 #47
0
 public void BeginShape(SpatialType spatialType)
 {
     this.drawGeometry.BeginGeometry(spatialType);
 }
コード例 #48
0
        private static CallSequenceLoggingPipeline ExecuteSendToPipeline(SpatialType spatialType, IEnumerable<object> coordinates, bool isGeography = true, IDictionary<string, object> crs = null)
        {
            var members = GetJsonMembers(spatialType, coordinates, crs);

            var actualPipeline = new CallSequenceLoggingPipeline();
            SendToPipeline(members, actualPipeline, isGeography);
            return actualPipeline;
        }
コード例 #49
0
        private static Dictionary<string, object> GetGeoJson(SpatialType? spatialType, List<object> coordinates, out int expectedPropertyCount, int? epsgId = null)
        {
            expectedPropertyCount = 0;
            //var geoJsonBuilder = new StringBuilder();
            var jsonObject = new Dictionary<string, object>();

            // Write the start of the object
            //geoJsonBuilder.Append("\n  \t{   ");

            // Write the "type" member if one was specified
            if (spatialType != null)
            {
                expectedPropertyCount++;
                //geoJsonBuilder.AppendFormat("{0}type{0}  : {1}{2}{1}", memberQuoteChar, typeValueQuoteChar, spatialType != SpatialType.Collection ? spatialType.ToString() : "GeometryCollection");
                jsonObject.Add("type", GetGeoJsonTypeName(spatialType.Value));
            }

            // Write the "coordinates" member if one was specified
            if (coordinates != null)
            {
                //if (spatialType != null)
                //{
                //    geoJsonBuilder.Append(",    ");
                //}

                expectedPropertyCount++;
                jsonObject.Add("coordinates", coordinates);
                //geoJsonBuilder.AppendFormat("{0}coordinates{0}:    ", memberQuoteChar);
                //WriteArray(geoJsonBuilder, coordinates);
            }

            // write the CRS member if an SRID was given
            if (epsgId != null)
            {
                //if (coordinates != null || spatialType != null)
                //{
                //    geoJsonBuilder.Append(",    ");
                //}

                //geoJsonBuilder.AppendFormat("    {0}crs{0}  : {{   {0}properties{0}:   {{ {0}name{0} : {1}EPSG:{2}{1}   }},   {0}type{0} : {1}name{1}   }}", memberQuoteChar, typeValueQuoteChar, epsgId.Value);
                jsonObject.Add("crs", GetCrsObject(epsgId));
                expectedPropertyCount++;
            }

            // Write the end of the object
            //geoJsonBuilder.Append(" \n}\n\r  ");

            //geoJsonInput = geoJsonBuilder.ToString();
            //return expectedPropertyCount;
            return jsonObject;
        }
コード例 #50
0
 internal override void BeginGeo(SpatialType type)
 {
     this.output.BeginGeography(type);
 }
コード例 #51
0
        private static void TestSendToPipeline(SpatialType spatialType, List<object> coordinates, bool isGeography, Func<List<object>, bool, ICommonLoggingPipeline> getExpectedPipeline)
        {
            // Set up expected call sequence
            var expectedPipeline = getExpectedPipeline(coordinates, isGeography);

            // Execute actual write to pipeline
            var actualPipeline = ExecuteSendToPipeline(spatialType, coordinates, isGeography);
            expectedPipeline.VerifyPipeline(actualPipeline);
        }
コード例 #52
0
        public virtual void Select(ISpatialDisplay display, IPosition p, SpatialType spatialType)
        {
            if (m_Data==null)
                return;

            // Use a tolerance of 2mm at the map scale of the supplied display
            ILength size = new Length(0.002 * display.MapScale);

            ISpatialObject so = m_Data.QueryClosest(p, size, spatialType);
            SetSelection(new SpatialSelection(so));
        }
コード例 #53
0
ファイル: DrawBoth.cs プロジェクト: smasonuk/odata-sparql
 /// <summary>
 /// Begin drawing a spatial object
 /// </summary>
 /// <param name="type">The spatial type of the object</param>
 /// <returns>The type to be passed down the pipeline</returns>
 protected virtual SpatialType OnBeginGeometry(SpatialType type)
 {
     return type;
 }
コード例 #54
0
ファイル: DrawBoth.cs プロジェクト: smasonuk/odata-sparql
 /// <summary>
 /// Begin drawing a spatial object
 /// </summary>
 /// <param name="type">The spatial type of the object</param>
 public override void BeginGeometry(SpatialType type)
 {
     both.OnBeginGeometry(type);
 }
コード例 #55
0
 public bool IsValid(SpatialType t)
 {
     return (((t & SpatialType.Point)!=0 && IsPointValid) ||
             ((t & SpatialType.Line) !=0 && IsLineValid) ||
             ((t & SpatialType.Text) !=0 && IsTextValid) ||
             ((t & SpatialType.Polygon)!=0 && IsPolygonValid));
 }
コード例 #56
0
 public override void BeginGeography(SpatialType type)
 {
 }
コード例 #57
0
 private void BeginShape(PipelineMethod pipelineMethod, SpatialType type)
 {
     CheckAlwaysThrow();
     LogMethodCall(pipelineMethod, type);
 }
コード例 #58
0
        private static Dictionary<string, object> GetGeoJson(SpatialType[] collectionTypes, List<object>[] coordinates, out int expectedPropertyCount, int? epsgId = null)
        {
            expectedPropertyCount = 2;
            var geoJsonBuilder = new StringBuilder();
            var jsonObject = new Dictionary<string, object>();

            jsonObject.Add("type", "GeometryCollection");
            // Write the start of the object
            //geoJsonBuilder.Append("\n  \t{   ");
            //geoJsonBuilder.AppendFormat("{0}type{0}  : {1}GeometryCollection{1}", memberQuoteChar, typeValueQuoteChar);

            if (epsgId != null)
            {
                jsonObject.Add("crs", GetCrsObject(epsgId));
                //geoJsonBuilder.Append(",    ");
                //geoJsonBuilder.AppendFormat("    {0}crs{0}  : {{   {0}properties{0}:   {{ {0}name{0} : {1}EPSG:{2}{1}   }},   {0}type{0} : {1}name{1}   }}", memberQuoteChar, typeValueQuoteChar, epsgId.Value);
                expectedPropertyCount++;
            }

            List<Dictionary<string, object>> geometryObjects = new List<Dictionary<string, object>>();
            //geoJsonBuilder.AppendFormat(", {0}geometries{0}: [", memberQuoteChar);
            for (var i = 0; i < collectionTypes.Length; ++i)
            {
                //string innerJson;
                int throwAwayPropertyCount;
                var innerObject = GetGeoJson(collectionTypes[i], coordinates[i], out throwAwayPropertyCount);
                geometryObjects.Add(innerObject);
                //geoJsonBuilder.Append(innerJson);

                //if (i != collectionTypes.Length - 1)
                //{
                //    geoJsonBuilder.Append(",    ");
                //}
            }
            jsonObject.Add("geometries", geometryObjects);
            //geoJsonBuilder.Append("\n]\n}\n\r");
            //geoJsonInput = geoJsonBuilder.ToString();

            //return expectedPropertyCount;
            return jsonObject;
        }
コード例 #59
0
        private static ICommonLoggingPipeline GetExpectedPipeline(SpatialType spatialType, CoordinateSystem coordinateSystem, bool isGeography, Action<ICommonLoggingPipeline> writeShape)
        {
            ICommonLoggingPipeline expectedPipeline;
            if (isGeography)
            {
                expectedPipeline = new GeographyLoggingPipeline();
            }
            else
            {
                expectedPipeline = new GeometryLoggingPipeline();
            }

            expectedPipeline.SetCoordinateSystem(coordinateSystem);
            expectedPipeline.BeginShape(spatialType);
            writeShape(expectedPipeline);
            expectedPipeline.EndShape();
            return expectedPipeline;
        }
コード例 #60
0
 public override void BeginGeometry(SpatialType type)
 {
 }