Complete Note#1 in the http://wiki.osgeo.org/wiki/GEOS_Provenance_Review to get out...
[geos.git] / include / geos / algorithm / InteriorPointArea.h
blob95b016a357e0af13b8d1153f2ce27df0ff0927c9
1 /**********************************************************************
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
6 * Copyright (C) 2005-2006 Refractions Research Inc.
7 * Copyright (C) 2001-2002 Vivid Solutions Inc.
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Public Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
14 **********************************************************************/
16 #ifndef GEOS_ALGORITHM_INTERIORPOINTAREA_H
17 #define GEOS_ALGORITHM_INTERIORPOINTAREA_H
19 #include <geos/export.h>
20 #include <geos/geom/Coordinate.h>
22 // Forward declarations
23 namespace geos {
24 namespace geom {
25 class Geometry;
26 class LineString;
27 class GeometryFactory;
28 class GeometryCollection;
33 namespace geos {
34 namespace algorithm { // geos::algorithm
36 /** \brief
37 * Computes a point in the interior of an area geometry.
39 * <h2>Algorithm</h2>
40 * <ul>
41 * <li>Find the intersections between the geometry
42 * and the horizontal bisector of the area's envelope
43 * <li>Pick the midpoint of the largest intersection (the intersections
44 * will be lines and points)
45 * </ul>
47 * <b>
48 * Note: If a fixed precision model is used,
49 * in some cases this method may return a point
50 * which does not lie in the interior.
51 * </b>
53 class GEOS_DLL InteriorPointArea {
55 private:
57 bool foundInterior;
59 const geom::GeometryFactory *factory;
61 geom::Coordinate interiorPoint;
63 double maxWidth;
65 void add(const geom::Geometry *geom);
67 const geom::Geometry *widestGeometry(const geom::Geometry *geometry);
69 const geom::Geometry *widestGeometry(const geom::GeometryCollection *gc);
71 geom::LineString *horizontalBisector(const geom::Geometry *geometry);
73 public:
75 InteriorPointArea(const geom::Geometry *g);
77 ~InteriorPointArea();
79 bool getInteriorPoint(geom::Coordinate& ret) const;
81 /** \brief
82 * Finds a reasonable point at which to label a Geometry.
84 * @param geometry the geometry to analyze
85 * @return the midpoint of the largest intersection between the geometry and
86 * a line halfway down its envelope
88 void addPolygon(const geom::Geometry *geometry);
92 } // namespace geos::algorithm
93 } // namespace geos
95 #endif // GEOS_ALGORITHM_INTERIORPOINTAREA_H
97 /**********************************************************************
98 * $Log$
99 * Revision 1.1 2006/03/09 16:46:48 strk
100 * geos::geom namespace definition, first pass at headers split
102 **********************************************************************/