Complete Note#1 in the http://wiki.osgeo.org/wiki/GEOS_Provenance_Review to get out...
[geos.git] / src / geom / prep / PreparedGeometryFactory.cpp
blobf96065bfdf1f39fb081c51e580cd379681239e90
1 /**********************************************************************
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
6 * Copyright (C) 2001-2002 Vivid Solutions Inc.
8 * This is free software; you can redistribute and/or modify it under
9 * the terms of the GNU Lesser General Public Licence as published
10 * by the Free Software Foundation.
11 * See the COPYING file for more information.
13 **********************************************************************
15 * Last port: geom/prep/PreparedGeometryFactory.java rev. 1.4 (JTS-1.10)
17 **********************************************************************/
20 #include <geos/geom/Point.h>
21 #include <geos/geom/MultiPoint.h>
22 #include <geos/geom/LineString.h>
23 #include <geos/geom/LinearRing.h>
24 #include <geos/geom/MultiLineString.h>
25 #include <geos/geom/Polygon.h>
26 #include <geos/geom/MultiPolygon.h>
27 #include <geos/geom/prep/PreparedGeometryFactory.h>
28 #include <geos/geom/prep/PreparedGeometry.h>
29 #include <geos/geom/prep/BasicPreparedGeometry.h>
30 #include <geos/geom/prep/PreparedPolygon.h>
31 #include <geos/geom/prep/PreparedLineString.h>
32 #include <geos/geom/prep/PreparedPoint.h>
33 #include <geos/util/IllegalArgumentException.h>
35 namespace geos {
36 namespace geom { // geos.geom
37 namespace prep { // geos.geom.prep
39 const PreparedGeometry *
40 PreparedGeometryFactory::create( const geom::Geometry * g) const
42 using geos::geom::GeometryTypeId;
44 if (0 == g)
46 throw util::IllegalArgumentException("PreparedGeometry constructd with null Geometry object");
49 PreparedGeometry* pg = 0;
51 switch ( g->getGeometryTypeId() )
53 case GEOS_MULTIPOINT:
54 case GEOS_POINT:
55 pg = new PreparedPoint( g);
56 break;
58 case GEOS_LINEARRING:
59 case GEOS_LINESTRING:
60 case GEOS_MULTILINESTRING:
61 pg = new PreparedLineString( g);
62 break;
64 case GEOS_POLYGON:
65 case GEOS_MULTIPOLYGON:
66 pg = new PreparedPolygon( g);
67 break;
69 default:
70 pg = new BasicPreparedGeometry( g);
72 return pg;
75 } // namespace geos.geom.prep
76 } // namespace geos.geom
77 } // namespace geos
79 /**********************************************************************
80 * $Log$
82 **********************************************************************/