00001 /********************************************************************** 00002 * $Id: PreparedLineStringIntersects.h 2812 2009-12-08 17:42:59Z strk $ 00003 * 00004 * GEOS - Geometry Engine Open Source 00005 * http://geos.refractions.net 00006 * 00007 * Copyright (C) 2006 Refractions Research Inc. 00008 * 00009 * This is free software; you can redistribute and/or modify it under 00010 * the terms of the GNU Lesser General Public Licence as published 00011 * by the Free Software Foundation. 00012 * See the COPYING file for more information. 00013 * 00014 * 00015 ********************************************************************** 00016 * 00017 * Last port: geom/prep/PreparedLineStringIntersects.java rev 1.2 (JTS-1.10) 00018 * 00019 **********************************************************************/ 00020 00021 #ifndef GEOS_GEOM_PREP_PREPAREDLINESTRINGINTERSECTS_H 00022 #define GEOS_GEOM_PREP_PREPAREDLINESTRINGINTERSECTS_H 00023 00024 #include <geos/geom/prep/PreparedLineString.h> 00025 #include <geos/algorithm/PointLocator.h> 00026 #include <geos/geom/util/ComponentCoordinateExtracter.h> 00027 #include <geos/geom/Coordinate.h> 00028 #include <geos/noding/SegmentStringUtil.h> 00029 00030 using namespace geos::algorithm; 00031 using namespace geos::geom::util; 00032 00033 namespace geos { 00034 namespace geom { // geos::geom 00035 namespace prep { // geos::geom::prep 00036 00048 class PreparedLineStringIntersects 00049 { 00050 public: 00051 00060 static bool intersects( PreparedLineString & prep, const geom::Geometry * geom ) 00061 { 00062 PreparedLineStringIntersects op( prep); 00063 return op.intersects( geom); 00064 } 00065 00069 PreparedLineStringIntersects(PreparedLineString & prep) 00070 : prepLine( prep) 00071 { } 00072 00079 bool intersects(const geom::Geometry * g) const; 00080 00081 protected: 00082 PreparedLineString & prepLine; 00083 //PreparedLineString * prepLine; 00084 00093 bool isAnyTestPointInTarget(const geom::Geometry * testGeom) const; 00094 //{ 00095 // /** 00096 // * This could be optimized by using the segment index on the lineal target. 00097 // * However, it seems like the L/P case would be pretty rare in practice. 00098 // */ 00099 // PointLocator * locator = new PointLocator(); 00100 00101 // geom::Coordinate::ConstVect coords; 00102 // ComponentCoordinateExtracter::getCoordinates( *testGeom, coords); 00103 00104 // for (size_t i=0, n=coords.size(); i<n; i++) 00105 // { 00106 // geom::Coordinate c = *(coords[i]); 00107 // if ( locator->intersects( c, &(prepLine->getGeometry()) )) 00108 // return true; 00109 // } 00110 // return false; 00111 //} 00112 00113 // Declare type as noncopyable 00114 PreparedLineStringIntersects(const PreparedLineStringIntersects& other); 00115 PreparedLineStringIntersects& operator=(const PreparedLineStringIntersects& rhs); 00116 }; 00117 00118 } // namespace geos::geom::prep 00119 } // namespace geos::geom 00120 } // namespace geos 00121 00122 #endif // GEOS_GEOM_PREP_PREPAREDLINESTRINGINTERSECTS_H 00123 /********************************************************************** 00124 * $Log$ 00125 **********************************************************************/ 00126