01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library 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 GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.gml;
17:
18: import com.vividsolutions.jts.geom.Coordinate;
19: import com.vividsolutions.jts.geom.Geometry;
20: import com.vividsolutions.jts.geom.GeometryFactory;
21: import com.vividsolutions.jts.geom.Point;
22:
23: /**
24: * Creates an OGC simple point.
25: *
26: * @author Ian Turton, CCG
27: * @author Rob Hranac, Vision for New York
28: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/main/java/org/geotools/gml/SubHandlerPoint.java $
29: * @version $Id: SubHandlerPoint.java 26168 2007-07-06 19:58:03Z jgarnett $
30: */
31: public class SubHandlerPoint extends SubHandler {
32: /** The coordinate of the point. */
33: Coordinate coordinate = null;
34:
35: /**
36: * Creates a new instance of GMLPointHandler.
37: */
38: public SubHandlerPoint() {
39: }
40:
41: /**
42: * Sets the coordinate for the point.
43: *
44: * @param coordinate Coordinate.
45: */
46: public void addCoordinate(Coordinate coordinate) {
47: this .coordinate = coordinate;
48: }
49:
50: /**
51: * Determines whether or not this Point is ready to be created.
52: *
53: * @param message GML element that prompted this query.
54: *
55: * @return Ready for creation flag.
56: */
57: public boolean isComplete(String message) {
58: if (this .coordinate != null) {
59: return true;
60: } else {
61: return false;
62: }
63: }
64:
65: /**
66: * Generates the point.
67: *
68: * @param geometryFactory Geometry factory to be used to create the point.
69: *
70: * @return Created Point.
71: */
72: public Geometry create(GeometryFactory geometryFactory) {
73: Point point = geometryFactory.createPoint(coordinate);
74: point.setUserData(getSRS());
75: point.setSRID(getSRID());
76: return point;
77: }
78: }
|