示例#1
0
        public override List <MatchedAddress> FindAddressCandidates(params AddressValue[] values)
        {
            ValidateAddressValues(values);
            RecordSet recordSet = GeocodeServer.FindAddressCandidates(ConvertAddressValuesToProperties(values), GetModifiedLocatorProperties());

            List <MatchedAddress> matchedAddresses = new List <MatchedAddress>();

            if (recordSet != null && recordSet.Records != null)
            {
                var select = recordSet.Fields.FieldArray.Select((field, index) => new { field, index });

                var result       = select.FirstOrDefault(o => o.field.Name == "Match_addr");
                int addressIndex = result == null ? -1 : result.index;

                result = select.FirstOrDefault(o => o.field.Name == "Score");
                int scoreIndex = result == null ? -1 : result.index;

                result = select.FirstOrDefault(o => o.field.Name == "Shape");
                int shapeIndex = result == null ? -1 : result.index;

                foreach (Record record in recordSet.Records)
                {
                    MatchedAddress matchedAddress = new MatchedAddress();

                    if (addressIndex > -1)
                    {
                        matchedAddress.Address = record.Values[addressIndex].ToString();
                    }

                    if (scoreIndex > -1)
                    {
                        matchedAddress.Score = Convert.ToInt32(record.Values[scoreIndex]);
                    }

                    if (shapeIndex > -1)
                    {
                        matchedAddress.Location = ((AppGeo.Clients.Ags.Proxy.Geometry)record.Values[shapeIndex]).ToCommon().Centroid.Coordinate;
                    }

                    matchedAddresses.Add(matchedAddress);
                }
            }

            return(matchedAddresses);
        }
示例#2
0
        public override MatchedAddress GeocodeAddress(params AddressValue[] values)
        {
            ValidateAddressValues(values);
            PropertySet propertySet = GeocodeServer.GeocodeAddress(ConvertAddressValuesToProperties(values), GetModifiedLocatorProperties());

            MatchedAddress matchedAddress = null;

            if (propertySet != null && propertySet.PropertyArray != null || propertySet.PropertyArray.Length > 0)
            {
                PropertySetProperty prop = propertySet.PropertyArray.FirstOrDefault(o => o.Key == "Status");

                if (prop != null && prop.Value.ToString() == "M")
                {
                    matchedAddress = new MatchedAddress();

                    prop = propertySet.PropertyArray.FirstOrDefault(o => o.Key == "Match_addr");

                    if (prop != null)
                    {
                        matchedAddress.Address = prop.Value.ToString();
                    }

                    prop = propertySet.PropertyArray.FirstOrDefault(o => o.Key == "Score");

                    if (prop != null)
                    {
                        matchedAddress.Score = Convert.ToInt32(prop.Value);
                    }

                    prop = propertySet.PropertyArray.FirstOrDefault(o => o.Key == "Shape");

                    if (prop != null)
                    {
                        matchedAddress.Location = ((AppGeo.Clients.Ags.Proxy.Geometry)prop.Value).ToCommon().Centroid.Coordinate;
                    }
                }
            }

            return(matchedAddress);
        }
示例#3
0
        public override void Reload()
        {
            Fields fields = GeocodeServer.GetAddressFields();

            AddressFields = fields.FieldArray.Select(o => new AgsField(o)).Cast <CommonField>().ToList();

            _locatorProperties = GeocodeServer.GetLocatorProperties();

            PropertySetProperty prop = _locatorProperties.PropertyArray.FirstOrDefault(o => o.Key == "MinimumMatchScore");

            if (prop != null)
            {
                MinimumScore = Convert.ToInt32(prop.Value);
            }

            prop = _locatorProperties.PropertyArray.FirstOrDefault(o => o.Key == "SpellingSensitivity");

            if (prop != null)
            {
                SpellingSensitivity = Convert.ToInt32(prop.Value);
            }
        }
        private IEnumerator AddStreetAddress(Vector3 position)
        {
            // Get UL and LR coordinates
            var tileUL = this._place.Location.ToTile(this._place.Level);
            var tileLR = new Tile()
            {
                Zoom = tileUL.Zoom,
                X    = tileUL.X + 1,
                Y    = tileUL.Y + 1
            };
            var coordUL = tileUL.UpperLeft;
            var coordLR = tileLR.UpperLeft;

            // Get tapped location relative to lower left.
            GameObject terrain  = GameObject.Find("terrain");
            var        location = position - terrain.transform.position;

            var longitude  = coordUL.Longitude + (coordLR.Longitude - coordUL.Longitude) * (location.x / SIZE);
            var lattitude  = coordLR.Latitude + (coordUL.Latitude - coordLR.Latitude) * (location.z / SIZE);
            var coordinate = new Coordinate()
            {
                Longitude = longitude,
                Latitude  = lattitude
            };

            // Retrieve address.
            this.StartCoroutine(GeocodeServer.ReverseGeocode(coordinate, address => {
                // Exit if no address found.
                if (address == null)
                {
                    System.Diagnostics.Debug.WriteLine("No Address");
                    return;
                }

                // Create leader line.
                GameObject line       = new GameObject();
                line.transform.parent = terrain.transform;
                line.tag = "addressmark";

                LineRenderer lineRenderer = line.AddComponent <LineRenderer>();
                lineRenderer.material     = new Material(Shader.Find("Standard"))
                {
                    color = Color.white
                };
                lineRenderer.SetWidth(0.002f, 0.002f);
                lineRenderer.SetVertexCount(2);
                lineRenderer.SetPositions(new Vector3[] {
                    position,
                    position + Vector3.up * 0.15f
                });
                lineRenderer.receiveShadows    = false;
                lineRenderer.shadowCastingMode = ShadowCastingMode.Off;
                lineRenderer.useWorldSpace     = false;

                // Add text
                GameObject text       = new GameObject();
                text.transform.parent = terrain.transform;
                text.tag = "addressmark";
                text.transform.position   = position + Vector3.up * 0.15f;
                text.transform.localScale = new Vector3(0.002f, 0.002f, 1f);

                TextMesh textMesh = text.AddComponent <TextMesh>();
                textMesh.text     = address.SingleLine;
                textMesh.anchor   = TextAnchor.LowerCenter;
                textMesh.fontSize = 50;
                textMesh.richText = true;

                textMesh.color = Color.green;

                Billboard billboard = text.AddComponent <Billboard>();
                billboard.PivotAxis = PivotAxis.Y;
            }));
            yield return(null);
        }