01: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
02: * This code is licensed under the GPL 2.0 license, availible at the root
03: * application directory.
04: */
05: package org.geoserver.wms.kvp;
06:
07: import org.geoserver.ows.KvpParser;
08: import org.geoserver.ows.util.KvpUtils;
09: import org.vfny.geoserver.ServiceException;
10: import java.awt.geom.Point2D;
11: import java.util.List;
12:
13: public class TilesOriginKvpParser extends KvpParser {
14: public TilesOriginKvpParser() {
15: super ("tilesorigin", Point2D.Double.class);
16: }
17:
18: public Object parse(String value) throws Exception {
19: List coordValues = KvpUtils.readFlat(value);
20:
21: if (coordValues.size() != 2) {
22: throw new ServiceException(value
23: + " is not a valid coordinate", getClass()
24: .getName());
25: }
26:
27: try {
28: double minx = Double.parseDouble(coordValues.get(0)
29: .toString());
30: double miny = Double.parseDouble(coordValues.get(1)
31: .toString());
32:
33: return new Point2D.Double(minx, miny);
34: } catch (NumberFormatException ex) {
35: throw new ServiceException(
36: ex,
37: "Illegal value for TILESORIGIN parameter: " + value,
38: getClass().getName() + "::parseTilesOrigin()");
39: }
40: }
41: }
|