Esempio n. 1
0
        private object ParsePoint(WktTokenQueue tokens)
        {
            tokens.Dequeue("POINT");
            var dimensions = ParseDimensions(tokens);

            if (tokens.NextTokenIs("EMPTY"))
            {
                tokens.Dequeue();
                return(_shapeConverter.ToPoint(null));
            }

            tokens.Dequeue(WktTokenType.LeftParenthesis);
            var coordinate = ParseCoordinate(tokens, dimensions);

            tokens.Dequeue(WktTokenType.RightParenthesis);
            return(_shapeConverter.ToPoint(coordinate));
        }
        private bool TryReadGeoPoint(string value, out object result)
        {
            var match = Regex.Match(value,
                                    @"^ \s* ([+-]?(?:\d+\.?\d*|\d*\.?\d+)) \s* , \s* ([+-]?(?:\d+\.?\d*|\d*\.?\d+)) \s* $",
                                    RegexOptions.IgnorePatternWhitespace | RegexOptions.IgnoreCase);

            if (match.Success)
            {
                result = _shapeConverter.ToPoint(new CoordinateInfo
                {
                    X = double.Parse(match.Groups[2].Value, CultureInfo.InvariantCulture),
                    Y = double.Parse(match.Groups[1].Value, CultureInfo.InvariantCulture)
                });
                return(true);
            }
            result = null;
            return(false);
        }
        private bool TryParsePoint(RavenJObject obj, out object result)
        {
            result = null;
            RavenJToken coord;

            if (obj.TryGetValue("coordinates", out coord))
            {
                var coordinates = coord as RavenJArray;

                if (coordinates == null || coordinates.Length < 2)
                {
                    return(false);
                }

                CoordinateInfo coordinate;
                if (TryParseCoordinate(coordinates, out coordinate))
                {
                    result = _shapeConverter.ToPoint(coordinate);
                    return(true);
                }
            }
            return(false);
        }