Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscellaneous #2354

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/osgEarth/ElevationLayer
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/osgEarth/ElevationPool
Original file line number Diff line number Diff line change
Expand Up @@ -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<ElevationTexture> getOrCreateRaster(
Expand Down
4 changes: 2 additions & 2 deletions src/osgEarth/Ellipsoid
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/osgEarth/ExampleResources
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ 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<osg::Node> loadWithoutControls(
osg::ArgumentParser& args,
osgViewer::ViewerBase* viewer) const;

/**
* Loads a map file and processes all the built-in example command line
* arguemnts and XML externals.
* arguments and XML externals.
*/
osg::ref_ptr<osg::Node> load(
osg::ArgumentParser& args,
Expand Down
8 changes: 4 additions & 4 deletions src/osgEarth/FeatureElevationLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -129,10 +133,6 @@ FeatureElevationLayer::addedToMap(const Map* map)
}
setDataExtents(dataExtents);
#endif

setProfile(
map->getProfile() != nullptr ? map->getProfile() :
Profile::create(Profile::GLOBAL_GEODETIC));
}

void
Expand Down
6 changes: 3 additions & 3 deletions src/osgEarth/GeoData
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/osgEarth/Geometry
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions src/osgEarth/Layer
Original file line number Diff line number Diff line change
Expand Up @@ -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:
*
Expand Down Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand Down
10 changes: 5 additions & 5 deletions src/osgEarth/Map
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ namespace osgEarth
template<typename T>
Revision getOpenLayers(std::vector< osg::ref_ptr<T> >& 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<typename T>
Revision getLayers(
Expand All @@ -142,7 +142,7 @@ namespace osgEarth
osg::MixinVector<osg::ref_ptr<T>>& output,
const std::function<bool(const Layer*)>& 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<typename T>
Revision getOpenLayers(osg::MixinVector< osg::ref_ptr<T> >& output) const;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/osgEarth/MapNode
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/osgEarth/OGRFeatureSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}


Expand Down
4 changes: 2 additions & 2 deletions src/osgEarth/SpatialReference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
}
Expand All @@ -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());
}
Expand Down
4 changes: 2 additions & 2 deletions src/osgEarth/TerrainMeshLayer
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion src/osgEarth/TileMesher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
43 changes: 42 additions & 1 deletion src/osgEarth/weemesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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<UID> 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> 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
Expand Down
2 changes: 1 addition & 1 deletion src/osgEarthDrivers/earth/EarthFileSerializer2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down