root/tools/routingservice/branches/wrs-2.0/src/util/format/GeoJSONTemplateFiller.java

Revision 312, 1.3 KB (checked in by anton, 19 months ago)

Double string format fixed, coordinate system format fixed

Line 
1package util.format;
2
3/*  WRS 2.0
4 *  Copyright (C) 2009 Anton Patrushev
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20import geometry.Point;
21
22import java.util.ArrayList;
23import java.util.Iterator;
24
25public class GeoJSONTemplateFiller extends TemplateFiller
26{
27
28        @Override
29        protected String getGeometryString(ArrayList<Point> points)
30        {
31                // For example:
32                // [102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]
33
34                StringBuffer out = new StringBuffer("");
35                Iterator<Point> it = points.iterator();
36                while (it.hasNext())
37                {
38                        Point point = it.next();
39                        out.append("[").append(getX(point));
40                        out.append(",");
41                        out.append(getY(point)).append("]");
42                        if (it.hasNext())
43                                out.append(", ");
44                }
45                return out.toString();
46        }
47
48}
Note: See TracBrowser for help on using the browser.