diff --git a/src/osgEarth/ElevationLayer b/src/osgEarth/ElevationLayer index 0f13ca1140..1080f8d149 100644 --- a/src/osgEarth/ElevationLayer +++ b/src/osgEarth/ElevationLayer @@ -124,7 +124,7 @@ namespace osgEarth virtual GeoHeightField createHeightFieldImplementation(const TileKey&, ProgressCallback* progress) const { return GeoHeightField::INVALID; } - //! Subalss can override this to enable writing heightfields. + //! Subclass can override this to enable writing heightfields. virtual Status writeHeightFieldImplementation( const TileKey& key, const osg::HeightField* hf, diff --git a/src/osgEarth/ElevationPool b/src/osgEarth/ElevationPool index 5344b3378c..673964998e 100644 --- a/src/osgEarth/ElevationPool +++ b/src/osgEarth/ElevationPool @@ -270,7 +270,7 @@ namespace osgEarth WorkingSet* ws, ProgressCallback* progress); - //! Best LOD this a point, or -1 if no data in index + //! Best LOD if this a point, or -1 if no data in index int getLOD(double x, double y) const; osg::ref_ptr getOrCreateRaster( diff --git a/src/osgEarth/Ellipsoid b/src/osgEarth/Ellipsoid index aa6812def1..10785fdd93 100644 --- a/src/osgEarth/Ellipsoid +++ b/src/osgEarth/Ellipsoid @@ -73,10 +73,10 @@ namespace osgEarth //! Get the coordinate frame at the geocentric point osg::Matrix geodeticToCoordFrame(const osg::Vec3d& xyz) const; - //! Converts degrees to meters at a given latitide + //! Converts degrees to meters at a given latitude double longitudinalDegreesToMeters(double value, double lat_deg = 0.0) const; - //! Converts meters to degrees at a given latitide + //! Converts meters to degrees at a given latitude double metersToLongitudinalDegrees(double value, double lat_deg =0.0) const; //! Geodesic distance in meters from one lat/long to another diff --git a/src/osgEarth/ExampleResources b/src/osgEarth/ExampleResources index 97f9309c56..03f646070c 100644 --- a/src/osgEarth/ExampleResources +++ b/src/osgEarth/ExampleResources @@ -67,7 +67,7 @@ namespace osgEarth { namespace Util public: /** * Loads a map file and processes all the built-in example command line - * arguemnts and XML externals. Disables the Controls library. + * arguments and XML externals. Disables the Controls library. */ osg::ref_ptr loadWithoutControls( osg::ArgumentParser& args, @@ -75,7 +75,7 @@ namespace osgEarth { namespace Util /** * Loads a map file and processes all the built-in example command line - * arguemnts and XML externals. + * arguments and XML externals. */ osg::ref_ptr load( osg::ArgumentParser& args, diff --git a/src/osgEarth/FeatureElevationLayer.cpp b/src/osgEarth/FeatureElevationLayer.cpp index 17104be767..5b74bf9118 100644 --- a/src/osgEarth/FeatureElevationLayer.cpp +++ b/src/osgEarth/FeatureElevationLayer.cpp @@ -106,6 +106,10 @@ FeatureElevationLayer::addedToMap(const Map* map) _extent = features->getFeatureProfile()->getExtent(); + setProfile( + map->getProfile() != nullptr ? map->getProfile() : + Profile::create(Profile::GLOBAL_GEODETIC)); + #if 0 // Add the bounds of the features DataExtent de(_extent, getMinLevel(), getMaxDataLevel()); @@ -129,10 +133,6 @@ FeatureElevationLayer::addedToMap(const Map* map) } setDataExtents(dataExtents); #endif - - setProfile( - map->getProfile() != nullptr ? map->getProfile() : - Profile::create(Profile::GLOBAL_GEODETIC)); } void diff --git a/src/osgEarth/GeoData b/src/osgEarth/GeoData index 9ab7af549f..bac0bfddca 100644 --- a/src/osgEarth/GeoData +++ b/src/osgEarth/GeoData @@ -298,7 +298,7 @@ namespace osgEarth /** - * A simple circular bounding area consiting of a GeoPoint and a linear radius. + * A simple circular bounding area consisting of a GeoPoint and a linear radius. */ class OSGEARTH_EXPORT GeoCircle { @@ -451,7 +451,7 @@ namespace osgEarth * * NOTE! It is possible that the target SRS will not be able to accomadate the * extents of the source SRS. (For example, transforming a full WGS84 extent - * to Mercator will resultin an error since Mercator does not cover the entire + * to Mercator will result in an error since Mercator does not cover the entire * globe.) Consider using Profile:clampAndTransformExtent() instead of using * this method directly. */ @@ -834,7 +834,7 @@ namespace osgEarth * @param srs * Spatial reference of the query coordinates. (If you pass in NULL, the method * will assume that the SRS is equivalent to that of the GeoHeightField. Be sure - * this is case of you will get incorrect results.) + * this is the case or you will get incorrect results.) * @param x, y * Coordinates at which to query the elevation value. * @param interp diff --git a/src/osgEarth/Geometry b/src/osgEarth/Geometry index 209b76f6ae..f8dc854a9e 100644 --- a/src/osgEarth/Geometry +++ b/src/osgEarth/Geometry @@ -198,6 +198,7 @@ namespace osgEarth //! to this geometry. //! A negative distance indicates that the point is interior //! to a ring or polygon. + //! Make sure to input a vector with z component zero! (or actually this series of function should be rewritten to drop the z component, the returned distance is the 3d distance with sign signaling interior or exterior in 2d!) virtual double getSignedDistance2D( const osg::Vec3d& point) const; @@ -335,7 +336,8 @@ namespace osgEarth bool getSegment(double length, osg::Vec3d& start, osg::Vec3d& end); virtual void close() override; - + + //! Make sure to input a vector with z component zero! (or actually this series of function should be rewritten to drop the z component, the returned distance is the 3d signed distance!) virtual double getSignedDistance2D( const osg::Vec3d& point) const override; @@ -383,6 +385,7 @@ namespace osgEarth // opens and winds the ring in the specified direction virtual void rewind( Orientation ori ); + //! Make sure to input a vector with z component zero! (or actually this series of function should be rewritten to drop the z component, the returned distance is the 3d signed distance!) virtual double getSignedDistance2D( const osg::Vec3d& a) const override; @@ -425,6 +428,7 @@ namespace osgEarth virtual void removeColinearPoints(); + //! Make sure to input a vector with z component zero! (or actually this series of function should be rewritten to drop the z component, the returned distance is the 3d signed distance!) virtual double getSignedDistance2D( const osg::Vec3d& a) const override; @@ -470,6 +474,7 @@ namespace osgEarth void open() override; virtual void close() override; + //! Make sure to input a vector with z component zero! (or actually this series of function should be rewritten to drop the z component, the returned distance is the 3d signed distance!) virtual double getSignedDistance2D( const osg::Vec3d& a) const override; diff --git a/src/osgEarth/Layer b/src/osgEarth/Layer index 0bfd4db17c..e8cdb0535b 100644 --- a/src/osgEarth/Layer +++ b/src/osgEarth/Layer @@ -164,7 +164,7 @@ namespace osgEarth * to establish the standard options framework. * * When you create a Layer, init() is called. Do all one-time construction - * activity where. + * activity there. * * When you add a Layer to a Map, the follow methods are called in order: * @@ -548,7 +548,7 @@ namespace osgEarth void Layer::setOptionThatRequiresReopen(T& target, const V& value) { if (target != value) { bool wasOpen = isOpen(); - if (wasOpen && !isOpening() && !isClosing()) close(); + if (wasOpen && !isOpening() && !isClosing()) close(); // so if a map is in the process of opening and an option is changed, this might not apply until re-opening again without notice target = value; if (wasOpen && !isOpening() && !isClosing()) open(); } @@ -557,7 +557,7 @@ namespace osgEarth void Layer::resetOptionThatRequiresReopen(T& target) { if (target.isSet()) { bool wasOpen = isOpen(); - if (wasOpen && !isOpening() && !isClosing()) close(); + if (wasOpen && !isOpening() && !isClosing()) close(); // same target.unset(); if (wasOpen && !isOpening() && !isClosing()) open(); } diff --git a/src/osgEarth/Map b/src/osgEarth/Map index 042867d8d2..0eb04f0d33 100644 --- a/src/osgEarth/Map +++ b/src/osgEarth/Map @@ -123,7 +123,7 @@ namespace osgEarth template Revision getOpenLayers(std::vector< osg::ref_ptr >& output) const; - //! Fills the vector with references to all layers satisflying the predicate + //! Fills the vector with references to all layers satisfying the predicate //! and returns the corresponding revision number. template Revision getLayers( @@ -142,7 +142,7 @@ namespace osgEarth osg::MixinVector>& output, const std::function& predicate) const; - //! Fills the vector with references to all layers of the specified type. + //! Fills the vector with references to all open layers of the specified type. //! and returns the corresponding revision number. template Revision getOpenLayers(osg::MixinVector< osg::ref_ptr >& output) const; @@ -177,7 +177,7 @@ namespace osgEarth const std::string& getMapName() const { return _name; } //! Cache for this Map. Set to NULL for no cache. - //! Only call this during intiailization. + //! Only call this during initialization. void setCache( Cache* cache ); Cache* getCache() const; @@ -207,7 +207,7 @@ namespace osgEarth //! List of attribution strings to be displayed by the application void getAttributions(StringSet& attributions) const; - //! Number of layers marked as terrain pathes + //! Number of layers marked as terrain patches int getNumTerrainPatchLayers() const; protected: @@ -238,7 +238,7 @@ namespace osgEarth const Map::Options& options, const osgDB::Options* readOptions); - //! Ready-only access to the serialization options for this map + //! Read-only access to the serialization options for this map const Options& options() const { return _optionsConcrete; } private: diff --git a/src/osgEarth/MapNode b/src/osgEarth/MapNode index 74aad22708..7a0c534fdd 100644 --- a/src/osgEarth/MapNode +++ b/src/osgEarth/MapNode @@ -81,7 +81,7 @@ namespace osgEarth public: // static loaders - //! Loads a MapNode form a ".earth" file in the arguemnts list + //! Loads a MapNode form a ".earth" file in the arguments list static MapNode* load(class osg::ArgumentParser& arguments); //! Loads a MapNode from a ".earth" file in the arguments list diff --git a/src/osgEarth/OGRFeatureSource.cpp b/src/osgEarth/OGRFeatureSource.cpp index 2268f6a500..6e5bc3a565 100644 --- a/src/osgEarth/OGRFeatureSource.cpp +++ b/src/osgEarth/OGRFeatureSource.cpp @@ -185,7 +185,7 @@ _rewindPolygons ( rewindPolygons ) _spatialFilter = OGR_G_CreateGeometry(wkbPolygon); OGR_G_AddGeometryDirectly(_spatialFilter, ring); - // note: "Directly" above means _spatialFilter takes ownership if ring handle + // note: "Directly" above means _spatialFilter takes ownership of ring handle } diff --git a/src/osgEarth/SpatialReference.cpp b/src/osgEarth/SpatialReference.cpp index 328a5df39c..7761752ab5 100644 --- a/src/osgEarth/SpatialReference.cpp +++ b/src/osgEarth/SpatialReference.cpp @@ -687,7 +687,7 @@ SpatialReference::createTransMercFromLongitude( const Angle& lon ) const std::string horiz = Stringify() << "+proj=tmerc +lat_0=0" << " +lon_0=" << lon.as(Units::DEGREES) - << " +datum=" << (!datum.empty() ? "WGS84" : datum); + << " +datum=" << (datum.empty() ? "WGS84" : datum); return SpatialReference::create( horiz, getVertInitString() ); } @@ -704,7 +704,7 @@ SpatialReference::createUTMFromLonLat(const Angle& lon, const Angle& lat) const std::string horiz = Stringify() << "+proj=utm +zone=" << zone << (lat.as(Units::DEGREES) < 0 ? " +south" : "") - << " +datum=" << (!datum.empty() ? "WGS84" : datum); + << " +datum=" << (datum.empty() ? "WGS84" : datum); return SpatialReference::create(horiz, getVertInitString()); } diff --git a/src/osgEarth/TerrainMeshLayer b/src/osgEarth/TerrainMeshLayer index c2592f7aa5..3dd76a25e4 100644 --- a/src/osgEarth/TerrainMeshLayer +++ b/src/osgEarth/TerrainMeshLayer @@ -58,8 +58,8 @@ namespace osgEarth public: // methods - //! Creates an image for the given tile key. - //! @param key TileKey for which to create an image + //! Creates a tile mesh for the given tile key. + //! @param key TileKey for which to create a tile mesh //! @param progress Optional progress/cancelation callback TileMesh createTile( const TileKey& key, diff --git a/src/osgEarth/TileMesher.cpp b/src/osgEarth/TileMesher.cpp index f4332ca352..e109bb5a44 100644 --- a/src/osgEarth/TileMesher.cpp +++ b/src/osgEarth/TileMesher.cpp @@ -557,7 +557,9 @@ TileMesher::createMeshWithConstraints( (p0.y >= ymin || p1.y >= ymin) && (p0.y <= ymax || p1.y <= ymax)) { - mesh.insert(weemesh::segment_t(p0, p1), marker); + weemesh::segment_t seg(p0, p1); + if(!mesh.update_existing_edge(seg,marker)) + mesh.insert(seg, marker); } } } diff --git a/src/osgEarth/weemesh.h b/src/osgEarth/weemesh.h index cbbfe30170..7b861e3a4b 100644 --- a/src/osgEarth/weemesh.h +++ b/src/osgEarth/weemesh.h @@ -471,7 +471,7 @@ namespace weemesh // The working set of triangles which we will add to if we have // to split triangles. Any triangle only needs to be split once, // even if it gets intersected multiple times. That is because each - // split generates new traigles, and discards the original, and further + // split generates new triangles, and discards the original, and further // splits will just happen on the new triangles later. (That's why // every split operation is followed by a "continue" to short-circuit // to loop) @@ -740,6 +740,47 @@ namespace weemesh else if (u > 1.0) return e2; else return e1 + qp * u; } + + bool update_existing_edge(const segment_t& seg, int marker) + { + // search for possible intersecting triangles: + vert_t::value_type a_min[2]; + vert_t::value_type a_max[2]; + a_min[0] = std::min(seg.first.x(), seg.second.x()); + a_min[1] = std::min(seg.first.y(), seg.second.y()); + a_max[0] = std::max(seg.first.x(), seg.second.x()); + a_max[1] = std::max(seg.first.y(), seg.second.y()); + std::vector uids; + + _spatial_index.Search( + a_min, a_max, + [&uids](const UID& u) { + uids.push_back(u); + return true; + }); + + vert_t::value_type E = EPSILON; // E = 1e-3; + std::list uid_list; + std::copy(uids.begin(), uids.end(), std::back_inserter(uid_list)); + for (auto uid : uid_list) + { + triangle_t& tri = _triangles[uid]; + + // check if a triangle contains those verts and update their markers + if (tri.contains_2d(seg.first) && tri.contains_2d(seg.second)) + { + vert_table_t::iterator i0 = _vert_lut.find(seg.first); + if (i0 != _vert_lut.end()) + _markers[i0->second] |= marker; + vert_table_t::iterator i1 = _vert_lut.find(seg.first); + if (i1 != _vert_lut.end()) + _markers[i1->second] |= marker; + // assume no further "close by" verts exist and exit after a first match + return true; + } + } + return false; + } }; // a graph node diff --git a/src/osgEarthDrivers/earth/EarthFileSerializer2.cpp b/src/osgEarthDrivers/earth/EarthFileSerializer2.cpp index 0e9361cbf2..3a4be0958f 100644 --- a/src/osgEarthDrivers/earth/EarthFileSerializer2.cpp +++ b/src/osgEarthDrivers/earth/EarthFileSerializer2.cpp @@ -85,7 +85,7 @@ namespace } // Config tags that we handle specially (versus just letting the plugin mechanism - // take take of them) + // take care of them) bool isReservedWord(const std::string& k) { return