GEOS
3.3.6
|
00001 /********************************************************************** 00002 * $Id: LinearLocation.h 2809 2009-12-06 01:05:24Z mloskot $ 00003 * 00004 * GEOS - Geometry Engine Open Source 00005 * http://geos.refractions.net 00006 * 00007 * Copyright (C) 2005-2006 Refractions Research Inc. 00008 * Copyright (C) 2001-2002 Vivid Solutions Inc. 00009 * 00010 * This is free software; you can redistribute and/or modify it under 00011 * the terms of the GNU Lesser General Public Licence as published 00012 * by the Free Software Foundation. 00013 * See the COPYING file for more information. 00014 * 00015 ********************************************************************** 00016 * 00017 * Last port: linearref/LinearLocation.java rev. 1.10 00018 * 00019 **********************************************************************/ 00020 00021 #ifndef GEOS_LINEARREF_LINEARLOCATION_H 00022 #define GEOS_LINEARREF_LINEARLOCATION_H 00023 00024 #include <string> 00025 #include <memory> // for std::auto_ptr 00026 00027 #include <geos/geom/Coordinate.h> 00028 #include <geos/geom/Geometry.h> 00029 #include <geos/geom/LineSegment.h> 00030 00031 namespace geos { 00032 namespace linearref { // geos::linearref 00033 00034 00043 class LinearLocation 00044 { 00045 private: 00046 unsigned int componentIndex; 00047 unsigned int segmentIndex; 00048 double segmentFraction; 00049 00057 void normalize(); 00058 00059 public: 00065 static LinearLocation getEndLocation(const geom::Geometry* linear); 00066 00082 static geom::Coordinate pointAlongSegmentByFraction(const geom::Coordinate& p0, const geom::Coordinate& p1, double frac); 00083 00084 00088 LinearLocation(unsigned int segmentIndex = 0, double segmentFraction = 0.0); 00089 00090 LinearLocation(unsigned int componentIndex, unsigned int segmentIndex, double segmentFraction); 00091 00097 void clamp(const geom::Geometry* linear); 00098 00107 void snapToVertex(const geom::Geometry* linearGeom, double minDistance); 00108 00116 double getSegmentLength(const geom::Geometry* linearGeom) const; 00117 00124 void setToEnd(const geom::Geometry* linear); 00125 00131 unsigned int getComponentIndex() const; 00132 00138 unsigned int getSegmentIndex() const; 00139 00145 double getSegmentFraction() const; 00146 00152 bool isVertex() const; 00153 00162 geom::Coordinate getCoordinate(const geom::Geometry* linearGeom) const; 00163 00171 std::auto_ptr<geom::LineSegment> getSegment(const geom::Geometry* linearGeom) const; 00172 00180 bool isValid(const geom::Geometry* linearGeom) const; 00181 00190 int compareTo(const LinearLocation& other) const; 00191 00201 int compareLocationValues(unsigned int componentIndex1, unsigned int segmentIndex1, double segmentFraction1) const; 00202 00216 static int compareLocationValues( 00217 unsigned int componentIndex0, unsigned int segmentIndex0, double segmentFraction0, 00218 unsigned int componentIndex1, unsigned int segmentIndex1, double segmentFraction1); 00219 00227 bool isOnSameSegment(const LinearLocation& loc) const; 00228 00229 00230 friend std::ostream& operator<< (std::ostream& out, const LinearLocation& obj ); 00231 00232 }; 00233 00234 00235 } // namespace geos.linearref 00236 } // namespace geos 00237 00238 #endif