Пример #1
0
        /// <summary>
        /// Check if the housenumber is following the vertex sequence of the road.
        /// </summary>
        private static bool IsDirectionFollowRoad(GeocoderMatch geocoderMath)
        {
            int fromLeft  = Convert.ToInt32(geocoderMath.NameValuePairs["FromAddressLeft"], CultureInfo.InvariantCulture);
            int toLeft    = Convert.ToInt32(geocoderMath.NameValuePairs["ToAddressLeft"], CultureInfo.InvariantCulture);
            int fromRight = Convert.ToInt32(geocoderMath.NameValuePairs["FromAddressRight"], CultureInfo.InvariantCulture);
            int toRight   = Convert.ToInt32(geocoderMath.NameValuePairs["ToAddressRight"], CultureInfo.InvariantCulture);

            return((fromRight < toRight) && (fromLeft < toLeft));
        }
Пример #2
0
        private SearchResult GetSearchResult(Feature feature, GeocoderMatch geocoderMath)
        {
            LineShape roadSegment           = GetLineShape(feature); // Get the line segment of current feature.
            bool      isLeftSide            = geocoderMath.NameValuePairs["SideOfStreet"].Equals("Left", StringComparison.InvariantCultureIgnoreCase);
            bool      isFollowRoadDirection = IsDirectionFollowRoad(geocoderMath);

            // Get the roads which are intersetected with current road
            FeatureLayer roadFeatureLayer = ((LayerOverlay)Map1.Overlays[roadOverlayName]).Layers[0] as FeatureLayer;

            // Get segments intersected with start vertex
            RectangleShape       startVertextBbox         = BufferVertex(roadSegment.Vertices[0]);
            Collection <Feature> intersectedStartFeatures = roadFeatureLayer.FeatureSource.GetFeaturesInsideBoundingBox(startVertextBbox, new[] { "ROAD_NAME" });
            Feature startCrossFeature = GetCrossRoad(feature, isLeftSide, intersectedStartFeatures);

            // Get segments intersected with end vertex
            RectangleShape       endVertextBbox         = BufferVertex(roadSegment.Vertices[roadSegment.Vertices.Count - 1]);
            Collection <Feature> intersectedEndFeatures = roadFeatureLayer.FeatureSource.GetFeaturesInsideBoundingBox(endVertextBbox, new[] { "ROAD_NAME" });
            Feature endCrossFeature = GetCrossRoad(feature, isLeftSide, intersectedEndFeatures);

            // highlight the low and high cross streets.
            InMemoryFeatureLayer highlightRoadLayer = ((LayerOverlay)Map1.Overlays[roadHighlightOverlayName]).Layers[0] as InMemoryFeatureLayer;

            highlightRoadLayer.InternalFeatures.Clear();

            if (startCrossFeature != null)
            {
                highlightRoadLayer.InternalFeatures.Add(startCrossFeature);
            }
            if (endCrossFeature != null)
            {
                highlightRoadLayer.InternalFeatures.Add(endCrossFeature);
            }

            SearchResult searchResult = new SearchResult
            {
                LowHouseNo      = isLeftSide ? geocoderMath.NameValuePairs["FromAddressLeft"] : geocoderMath.NameValuePairs["FromAddressRight"],
                HighHouseNo     = isLeftSide ? geocoderMath.NameValuePairs["ToAddressLeft"] : geocoderMath.NameValuePairs["ToAddressRight"],
                StreetName      = geocoderMath.NameValuePairs["Street"],
                StreetType      = geocoderMath.NameValuePairs["StreetType"],
                LowCrossStreet  = isFollowRoadDirection ? (startCrossFeature != null ? startCrossFeature.ColumnValues["ROAD_NAME"] : "N/A") : (endCrossFeature != null ? endCrossFeature.ColumnValues["ROAD_NAME"] : "N/A"),
                HighCrossStreet = isFollowRoadDirection ? (endCrossFeature != null ? endCrossFeature.ColumnValues["ROAD_NAME"] : "N/A") : (startCrossFeature != null ? startCrossFeature.ColumnValues["ROAD_NAME"] : "N/A"),
            };

            return(searchResult);
        }