Ejemplo n.º 1
0
        /// <summary>
        /// Returns the next array of Coordinates in the stream.
        /// </summary>
        /// <param name="tokenizer">Tokenizer over a stream of text in Well-known Text format.  The
        /// next element returned by the stream should be "(" (the beginning of "(x1 y1, x2 y2, ..., xn yn)" or
        /// "EMPTY".</param>
        /// <returns>The next array of Coordinates in the stream, or an empty array of "EMPTY" is the
        /// next element returned by the stream.</returns>
        private Coordinates GetCoordinates(WktStreamTokenizer tokenizer)
        {
            Coordinates coordinates = new Coordinates();
            string      nextToken   = GetNextEmptyOrOpener(tokenizer);

            if (nextToken == "EMPTY")
            {
                return(coordinates);
            }
            Coordinate externalCoordinate = new Coordinate();
            Coordinate internalCoordinate = new Coordinate();

            externalCoordinate.X = GetNextNumber(tokenizer);
            externalCoordinate.Y = GetNextNumber(tokenizer);
            _precisionModel.ToInternal(externalCoordinate, internalCoordinate);
            coordinates.Add(internalCoordinate);
            nextToken = GetNextCloserOrComma(tokenizer);
            while (nextToken == ",")
            {
                externalCoordinate.X = this.GetNextNumber(tokenizer);
                externalCoordinate.Y = this.GetNextNumber(tokenizer);
                internalCoordinate   = new Coordinate();
                _precisionModel.ToInternal(externalCoordinate, internalCoordinate);
                coordinates.Add(internalCoordinate);
                nextToken = GetNextCloserOrComma(tokenizer);
            }
            return(coordinates);
            //Coordinate[] array = new Coordinate[coordinates.Count];
            //return (Coordinate[]) coordinates.ToArray(typeof(Coordinate));
        }