diff --git a/README.md b/README.md index a631fce..b179136 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,9 @@ ofxGeo A set of utilities and classes for common geographic tasks. -Also includes Geographic Lib http://geographiclib.sourceforge.net/html/ \ No newline at end of file +Also includes Geographic Lib http://geographiclib.sourceforge.net/html/ + +Notes: + +- Example `example_earth` requires https://github.com/bakercp/ofxSatellite and https://github.com/bakercp/ofxTime +- Example `example_spatial_hash` requires https://github.com/bakercp/ofxSpatialHash diff --git a/addon_config.mk b/addon_config.mk index 0290c95..8452e1b 100644 --- a/addon_config.mk +++ b/addon_config.mk @@ -4,7 +4,3 @@ meta: ADDON_AUTHOR = bakercp ADDON_TAGS = "geo" "mapping" "gps" ADDON_URL = http://github.com/bakercp/ofxGeo -common: - # dependencies with other addons, a list of them separated by spaces - # or use += in several lines - ADDON_DEPENDENCIES = ofxSpatialHash diff --git a/example_earth/Makefile b/example_earth/Makefile index 7a7fe8b..8d8e4c0 100644 --- a/example_earth/Makefile +++ b/example_earth/Makefile @@ -6,7 +6,7 @@ endif # make sure the the OF_ROOT location is defined ifndef OF_ROOT - OF_ROOT=../../.. + OF_ROOT=$(realpath ../../..) endif # call the project makefile! diff --git a/example_earth/addons.make b/example_earth/addons.make index 4916a80..bb22fd6 100644 --- a/example_earth/addons.make +++ b/example_earth/addons.make @@ -1,4 +1,3 @@ ofxGeo ofxSatellite -ofxSpatialHash ofxTime diff --git a/example_earth/src/main.cpp b/example_earth/src/main.cpp index 5b4520c..70c3278 100644 --- a/example_earth/src/main.cpp +++ b/example_earth/src/main.cpp @@ -1,6 +1,6 @@ // ============================================================================= // -// Copyright (c) 2013 Christopher Baker +// Copyright (c) 2013-2016 Christopher Baker // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -29,5 +29,5 @@ int main() { ofSetupOpenGL(1024, 768, OF_WINDOW); - ofRunApp(new ofApp()); + ofRunApp(std::make_shared()); } diff --git a/example_earth/src/ofApp.cpp b/example_earth/src/ofApp.cpp index 86625f7..50f9211 100644 --- a/example_earth/src/ofApp.cpp +++ b/example_earth/src/ofApp.cpp @@ -1,6 +1,6 @@ // ============================================================================= // -// Copyright (c) 2010-2014 Christopher Baker +// Copyright (c) 2010-2016 Christopher Baker // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -30,24 +30,24 @@ void ofApp::setup() { ofEnableDepthTest(); - london = Geo::Coordinate(51.5085300, -0.1257400); - tokyo = Geo::Coordinate(35.6148800, 139.5813000); + london = ofxGeo::Coordinate(51.5085300, -0.1257400); + tokyo = ofxGeo::Coordinate(35.6148800, 139.5813000); - colorMap.loadImage("color_map_1024.jpg"); + colorMap.load("color_map_1024.jpg"); - earthSphere.set(Geo::GeoUtils::EARTH_RADIUS_KM, 24); + earthSphere.set(ofxGeo::Utils::EARTH_RADIUS_KM, 24); ofQuaternion quat; quat.makeRotate(180, 0, 1, 0); earthSphere.rotate(quat); earthSphere.mapTexCoords(0, - colorMap.getTextureReference().getTextureData().tex_u, - colorMap.getTextureReference().getTextureData().tex_t, + colorMap.getTexture().getTextureData().tex_u, + colorMap.getTexture().getTextureData().tex_t, 0); - scaler = 300 / Geo::GeoUtils::EARTH_RADIUS_KM; + scaler = 300 / ofxGeo::Utils::EARTH_RADIUS_KM; ofSetFrameRate(30); ofEnableAlphaBlending(); @@ -77,14 +77,14 @@ void ofApp::draw() ofQuaternion longRot; ofQuaternion spinQuat; - Geo::ElevatedCoordinate pos(london.getLatitude(), london.getLongitude(), 0);//(-87.6278, 41.8819, 0); + ofxGeo::ElevatedCoordinate pos(london.getLatitude(), london.getLongitude(), 0);//(-87.6278, 41.8819, 0); latRot.makeRotate(pos.getLatitude(), 1, 0, 0); longRot.makeRotate(pos.getLongitude(), 0, 1, 0); // spinQuat.makeRotate(ofGetFrameNum()/100, 0, 1, 0); //our starting point is 0,0, on the surface of our sphere, this is where the meridian and equator meet - ofVec3f center = ofVec3f(0,0, pos.getElevation() / 1000 + Geo::GeoUtils::EARTH_RADIUS_KM); + ofVec3f center = ofVec3f(0,0, pos.getElevation() / 1000 + ofxGeo::Utils::EARTH_RADIUS_KM); //multiplying a quat with another quat combines their rotations into one quat //multiplying a quat to a vector applies the quat's rotation to that vector //so to to generate our point on the sphere, multiply all of our quaternions together then multiple the centery by the combined rotation @@ -92,11 +92,11 @@ void ofApp::draw() ofFill(); ofSetColor(255, 0, 0, 127); - ofCircle(worldPoint, 30); + ofDrawCircle(worldPoint, 30); ofNoFill(); ofSetColor(255, 0, 0, 255); - ofCircle(worldPoint, 30); + ofDrawCircle(worldPoint, 30); ofSetColor(255); diff --git a/example_earth/src/ofApp.h b/example_earth/src/ofApp.h index d29993e..e63a18a 100644 --- a/example_earth/src/ofApp.h +++ b/example_earth/src/ofApp.h @@ -1,6 +1,6 @@ // ============================================================================= // -// Copyright (c) 2013 Christopher Baker +// Copyright (c) 2013-2016 Christopher Baker // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -30,9 +30,6 @@ #include "ofxSatellite.h" -using namespace ofx; - - class ofApp: public ofBaseApp { public: @@ -42,8 +39,8 @@ class ofApp: public ofBaseApp void keyPressed(int key); - Geo::Coordinate london; - Geo::Coordinate tokyo; + ofxGeo::Coordinate london; + ofxGeo::Coordinate tokyo; float scaler; diff --git a/example_geographclib/Makefile b/example_geographclib/Makefile index 7a7fe8b..8d8e4c0 100644 --- a/example_geographclib/Makefile +++ b/example_geographclib/Makefile @@ -6,7 +6,7 @@ endif # make sure the the OF_ROOT location is defined ifndef OF_ROOT - OF_ROOT=../../.. + OF_ROOT=$(realpath ../../..) endif # call the project makefile! diff --git a/example_geographclib/addons.make b/example_geographclib/addons.make index f97cabd..b51f732 100644 --- a/example_geographclib/addons.make +++ b/example_geographclib/addons.make @@ -1,2 +1 @@ ofxGeo -ofxSpatialHash \ No newline at end of file diff --git a/example_geographclib/src/main.cpp b/example_geographclib/src/main.cpp index 2fe9b75..7f6128b 100644 --- a/example_geographclib/src/main.cpp +++ b/example_geographclib/src/main.cpp @@ -1,6 +1,6 @@ // ============================================================================= // -// Copyright (c) 2014 Christopher Baker +// Copyright (c) 2014-2016 Christopher Baker // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -29,5 +29,5 @@ int main() { ofSetupOpenGL(520, 94, OF_WINDOW); - ofRunApp(new ofApp()); + ofRunApp(std::make_shared()); } diff --git a/example_geographclib/src/ofApp.cpp b/example_geographclib/src/ofApp.cpp index c7ae35a..a75e809 100644 --- a/example_geographclib/src/ofApp.cpp +++ b/example_geographclib/src/ofApp.cpp @@ -1,6 +1,6 @@ // ============================================================================= // -// Copyright (c) 2014 Christopher Baker +// Copyright (c) 2014-2016 Christopher Baker // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -29,29 +29,28 @@ void ofApp::setup() { - london = Geo::Coordinate(51.5085300, -0.1257400); - tokyo = Geo::Coordinate(35.6148800, 139.5813000); + london = ofxGeo::Coordinate(51.5085300, -0.1257400); + tokyo = ofxGeo::Coordinate(35.6148800, 139.5813000); - distanceSpherical = Geo::GeoUtils::distanceSpherical(london, tokyo); - distanceHaversine = Geo::GeoUtils::distanceHaversine(london, tokyo); - bearingHaversine = Geo::GeoUtils::bearingHaversine(london, tokyo); - midpoint = Geo::GeoUtils::midpoint(london, tokyo); + distanceSpherical = ofxGeo::Utils::distanceSpherical(london, tokyo); + distanceHaversine = ofxGeo::Utils::distanceHaversine(london, tokyo); + bearingHaversine = ofxGeo::Utils::bearingHaversine(london, tokyo); + midpoint = ofxGeo::Utils::midpoint(london, tokyo); - try { + try + { // Miscellaneous conversions - double lat = 33.3, lon = 44.4; - GeographicLib::GeoCoords c(lat, lon); - cout << c.MGRSRepresentation(-3) << "\n"; + GeographicLib::GeoCoords c(33.3, 44.4); + std::cout << c.MGRSRepresentation(-3) << std::endl; c.Reset("18TWN0050"); - cout << c.DMSRepresentation() << "\n"; - cout << c.Latitude() << " " << c.Longitude() << "\n"; + std::cout << c.DMSRepresentation() << std::endl; + std::cout << c.Latitude() << " " << c.Longitude() << std::endl; c.Reset("1d38'W 55d30'N"); - cout << c.GeoRepresentation() << "\n"; - - cout << c.UTMUPSRepresentation() << endl; + std::cout << c.GeoRepresentation() << std::endl; + std::cout << c.UTMUPSRepresentation() << std::endl; } - catch (const exception& e) { - cerr << "Caught exception: " << e.what() << "\n"; + catch (const std::exception& e) { + std::cout << "Caught exception: " << e.what() << std::endl; } } @@ -63,8 +62,8 @@ void ofApp::draw() std::stringstream ss; - ss << "From: London (" << london << "), UTM [" << Geo::GeoUtils::toUTM(london) << "]" << std::endl; - ss << " To: Tokyo (" << tokyo << "), UTM [" << Geo::GeoUtils::toUTM(tokyo) << "]" << std::endl; + ss << "From: London (" << london << "), UTM [" << ofxGeo::Utils::toUTM(london) << "]" << std::endl; + ss << " To: Tokyo (" << tokyo << "), UTM [" << ofxGeo::Utils::toUTM(tokyo) << "]" << std::endl; ss << " Distance Spherical: " << distanceSpherical << " km" << std::endl; ss << " Distance Haversine: " << distanceHaversine << " km" << std::endl; ss << " Bearing Haversine: " << bearingHaversine << " degrees" << std::endl; diff --git a/example_geographclib/src/ofApp.h b/example_geographclib/src/ofApp.h index a95d22f..ee5452f 100644 --- a/example_geographclib/src/ofApp.h +++ b/example_geographclib/src/ofApp.h @@ -1,6 +1,6 @@ // ============================================================================= // -// Copyright (c) 2014 Christopher Baker +// Copyright (c) 2014-2016 Christopher Baker // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -30,22 +30,19 @@ #include "ofxGeo.h" -using namespace ofx; - - class ofApp: public ofBaseApp { public: void setup(); void draw(); - Geo::Coordinate london; - Geo::Coordinate tokyo; + ofxGeo::Coordinate london; + ofxGeo::Coordinate tokyo; double distanceSpherical; double distanceHaversine; double bearingHaversine; - Geo::Coordinate midpoint; + ofxGeo::Coordinate midpoint; }; diff --git a/example_measurement/Makefile b/example_measurement/Makefile index 7a7fe8b..8d8e4c0 100644 --- a/example_measurement/Makefile +++ b/example_measurement/Makefile @@ -6,7 +6,7 @@ endif # make sure the the OF_ROOT location is defined ifndef OF_ROOT - OF_ROOT=../../.. + OF_ROOT=$(realpath ../../..) endif # call the project makefile! diff --git a/example_measurement/addons.make b/example_measurement/addons.make index fd5e423..b51f732 100644 --- a/example_measurement/addons.make +++ b/example_measurement/addons.make @@ -1,2 +1 @@ ofxGeo -ofxSpatialHash diff --git a/example_measurement/src/main.cpp b/example_measurement/src/main.cpp index 2fe9b75..7f6128b 100644 --- a/example_measurement/src/main.cpp +++ b/example_measurement/src/main.cpp @@ -1,6 +1,6 @@ // ============================================================================= // -// Copyright (c) 2014 Christopher Baker +// Copyright (c) 2014-2016 Christopher Baker // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -29,5 +29,5 @@ int main() { ofSetupOpenGL(520, 94, OF_WINDOW); - ofRunApp(new ofApp()); + ofRunApp(std::make_shared()); } diff --git a/example_measurement/src/ofApp.cpp b/example_measurement/src/ofApp.cpp index f1b2d2e..872e94d 100644 --- a/example_measurement/src/ofApp.cpp +++ b/example_measurement/src/ofApp.cpp @@ -1,6 +1,6 @@ // ============================================================================= // -// Copyright (c) 2014 Christopher Baker +// Copyright (c) 2014-2016 Christopher Baker // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -28,13 +28,13 @@ void ofApp::setup() { - london = Geo::Coordinate(51.5085300, -0.1257400); - tokyo = Geo::Coordinate(35.6148800, 139.5813000); + london = ofxGeo::Coordinate(51.5085300, -0.1257400); + tokyo = ofxGeo::Coordinate(35.6148800, 139.5813000); - distanceSpherical = Geo::GeoUtils::distanceSpherical(london, tokyo); - distanceHaversine = Geo::GeoUtils::distanceHaversine(london, tokyo); - bearingHaversine = Geo::GeoUtils::bearingHaversine(london, tokyo); - midpoint = Geo::GeoUtils::midpoint(london, tokyo); + distanceSpherical = ofxGeo::Utils::distanceSpherical(london, tokyo); + distanceHaversine = ofxGeo::Utils::distanceHaversine(london, tokyo); + bearingHaversine = ofxGeo::Utils::bearingHaversine(london, tokyo); + midpoint = ofxGeo::Utils::midpoint(london, tokyo); } @@ -44,8 +44,8 @@ void ofApp::draw() std::stringstream ss; - ss << "From: London (" << london << "), UTM [" << Geo::GeoUtils::toUTM(london) << "]" << std::endl; - ss << " To: Tokyo (" << tokyo << "), UTM [" << Geo::GeoUtils::toUTM(tokyo) << "]" << std::endl; + ss << "From: London (" << london << "), UTM [" << ofxGeo::Utils::toUTM(london) << "]" << std::endl; + ss << " To: Tokyo (" << tokyo << "), UTM [" << ofxGeo::Utils::toUTM(tokyo) << "]" << std::endl; ss << " Distance Spherical: " << distanceSpherical << " km" << std::endl; ss << " Distance Haversine: " << distanceHaversine << " km" << std::endl; ss << " Bearing Haversine: " << bearingHaversine << " degrees" << std::endl; diff --git a/example_measurement/src/ofApp.h b/example_measurement/src/ofApp.h index a95d22f..9b69cbd 100644 --- a/example_measurement/src/ofApp.h +++ b/example_measurement/src/ofApp.h @@ -1,6 +1,6 @@ // ============================================================================= // -// Copyright (c) 2014 Christopher Baker +// Copyright (c) 2014-2016 Christopher Baker // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -30,22 +30,19 @@ #include "ofxGeo.h" -using namespace ofx; - - class ofApp: public ofBaseApp { public: void setup(); void draw(); - Geo::Coordinate london; - Geo::Coordinate tokyo; + ofxGeo::Coordinate london; + ofxGeo::Coordinate tokyo; - double distanceSpherical; - double distanceHaversine; - double bearingHaversine; + double distanceSpherical = 0; + double distanceHaversine = 0; + double bearingHaversine = 0; - Geo::Coordinate midpoint; + ofxGeo::Coordinate midpoint; }; diff --git a/example_polyline/Makefile b/example_polyline/Makefile index 7a7fe8b..8d8e4c0 100644 --- a/example_polyline/Makefile +++ b/example_polyline/Makefile @@ -6,7 +6,7 @@ endif # make sure the the OF_ROOT location is defined ifndef OF_ROOT - OF_ROOT=../../.. + OF_ROOT=$(realpath ../../..) endif # call the project makefile! diff --git a/example_polyline/addons.make b/example_polyline/addons.make index fd5e423..b51f732 100644 --- a/example_polyline/addons.make +++ b/example_polyline/addons.make @@ -1,2 +1 @@ ofxGeo -ofxSpatialHash diff --git a/example_polyline/src/main.cpp b/example_polyline/src/main.cpp index b2c1143..d63052f 100644 --- a/example_polyline/src/main.cpp +++ b/example_polyline/src/main.cpp @@ -1,6 +1,6 @@ // ============================================================================= // -// Copyright (c) 2014 Christopher Baker +// Copyright (c) 2014-2016 Christopher Baker // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -29,5 +29,5 @@ int main() { ofSetupOpenGL(310, 80, OF_WINDOW); - ofRunApp(new ofApp()); + ofRunApp(std::make_shared()); } diff --git a/example_polyline/src/ofApp.cpp b/example_polyline/src/ofApp.cpp index ceced14..ff9ed44 100644 --- a/example_polyline/src/ofApp.cpp +++ b/example_polyline/src/ofApp.cpp @@ -1,6 +1,6 @@ // ============================================================================= // -// Copyright (c) 2014 Christopher Baker +// Copyright (c) 2014-2016 Christopher Baker // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ void ofApp::setup() { encodedPolyline = "_p~iF~ps|U_ulLnnqC_mqNvxq`@"; - polyline = Geo::GeoUtils::decodeGeoPolyline(encodedPolyline); + polyline = ofxGeo::Utils::decodeGeoPolyline(encodedPolyline); } diff --git a/example_polyline/src/ofApp.h b/example_polyline/src/ofApp.h index 87cc2a8..96fb22d 100644 --- a/example_polyline/src/ofApp.h +++ b/example_polyline/src/ofApp.h @@ -1,6 +1,6 @@ // ============================================================================= // -// Copyright (c) 2014 Christopher Baker +// Copyright (c) 2014-2016 Christopher Baker // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -30,9 +30,6 @@ #include "ofxGeo.h" -using namespace ofx; - - class ofApp: public ofBaseApp { public: @@ -41,5 +38,5 @@ class ofApp: public ofBaseApp std::string encodedPolyline; - std::vector polyline; + std::vector polyline; }; diff --git a/example_spatial_hash/Makefile b/example_spatial_hash/Makefile index 7a7fe8b..8d8e4c0 100644 --- a/example_spatial_hash/Makefile +++ b/example_spatial_hash/Makefile @@ -6,7 +6,7 @@ endif # make sure the the OF_ROOT location is defined ifndef OF_ROOT - OF_ROOT=../../.. + OF_ROOT=$(realpath ../../..) endif # call the project makefile! diff --git a/example_spatial_hash/src/main.cpp b/example_spatial_hash/src/main.cpp index b2c1143..d63052f 100644 --- a/example_spatial_hash/src/main.cpp +++ b/example_spatial_hash/src/main.cpp @@ -1,6 +1,6 @@ // ============================================================================= // -// Copyright (c) 2014 Christopher Baker +// Copyright (c) 2014-2016 Christopher Baker // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -29,5 +29,5 @@ int main() { ofSetupOpenGL(310, 80, OF_WINDOW); - ofRunApp(new ofApp()); + ofRunApp(std::make_shared()); } diff --git a/example_spatial_hash/src/ofApp.cpp b/example_spatial_hash/src/ofApp.cpp index 9f7dc3a..0cb67fa 100644 --- a/example_spatial_hash/src/ofApp.cpp +++ b/example_spatial_hash/src/ofApp.cpp @@ -1,6 +1,6 @@ // ============================================================================= // -// Copyright (c) 2014 Christopher Baker +// Copyright (c) 2014-2016 Christopher Baker // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -37,10 +37,9 @@ void ofApp::setup() mesh.setMode(OF_PRIMITIVE_POINTS); - for (std::size_t i = 0; i < NUM; ++i) { - ofx::Geo::UTMLocation location = ofx::Geo::GeoUtils::randomUTMLocation(); + ofx::Geo::UTMLocation location = ofxGeo::Utils::randomUTMLocation(); locations.push_back(location); mesh.addVertex(ofVec3f(location.x, location.y)); diff --git a/example_spatial_hash/src/ofApp.h b/example_spatial_hash/src/ofApp.h index 92603ff..ba3d108 100644 --- a/example_spatial_hash/src/ofApp.h +++ b/example_spatial_hash/src/ofApp.h @@ -28,6 +28,7 @@ #include "ofMain.h" #include "ofxGeo.h" +#include "ofxSpatialHash.h" class ofApp: public ofBaseApp @@ -39,20 +40,20 @@ class ofApp: public ofBaseApp void draw(); // A collection of Random UTMCoordinates. - std::vector locations; + std::vector locations; /// \brief The spatial hash specialized for ofx::Geo::UTMLocation. /// /// We must also specify the - ofx::KDTree hash; + ofx::KDTree hash; /// \brief The search results specialized for ofx::Geo::UTMLocation. - ofx::KDTree::SearchResults searchResults; + ofx::KDTree::SearchResults searchResults; /// \brief A mesh to make it easier to draw lots of points. ofMesh mesh; - ofx::Geo::UTMLocation mouse; + ofxGeo::UTMLocation mouse; ofRectangled bounds; diff --git a/libs/ofxGeo/include/ofx/Geo/GeoUtils.h b/libs/ofxGeo/include/ofx/Geo/Utils.h similarity index 98% rename from libs/ofxGeo/include/ofx/Geo/GeoUtils.h rename to libs/ofxGeo/include/ofx/Geo/Utils.h index 98b4cec..d8feaea 100644 --- a/libs/ofxGeo/include/ofx/Geo/GeoUtils.h +++ b/libs/ofxGeo/include/ofx/Geo/Utils.h @@ -41,7 +41,7 @@ class UTMLocation; /// \brief A collection of utilities for geographic tasks. -class GeoUtils +class Utils { public: /// \brief Convert a string-encoded polyline into a vector of coodinates. @@ -150,6 +150,10 @@ class GeoUtils /// \brief The maximum value for a longitude, + 180 degrees. static const double MAX_LONGITUDE_DEGREES; +private: + Utils() = delete; + ~Utils() = delete; + }; diff --git a/libs/ofxGeo/src/CoordinateBounds.cpp b/libs/ofxGeo/src/CoordinateBounds.cpp index 839818c..9a2a4ed 100755 --- a/libs/ofxGeo/src/CoordinateBounds.cpp +++ b/libs/ofxGeo/src/CoordinateBounds.cpp @@ -39,7 +39,6 @@ CoordinateBounds::CoordinateBounds(const Coordinate& northwest, const Coordinate& southeast): _northwest(northwest), _southeast(southeast) - { } diff --git a/libs/ofxGeo/src/GeoUtils.cpp b/libs/ofxGeo/src/GeoUtils.cpp index c4bddd0..1f351dd 100644 --- a/libs/ofxGeo/src/GeoUtils.cpp +++ b/libs/ofxGeo/src/GeoUtils.cpp @@ -23,7 +23,7 @@ // ============================================================================= -#include "ofx/Geo/GeoUtils.h" +#include "ofx/Geo/Utils.h" #include "ofx/Geo/Coordinate.h" #include "ofx/Geo/UTMLocation.h" #include "UTM/UTM.h" @@ -35,18 +35,18 @@ namespace ofx { namespace Geo { -const double GeoUtils::EARTH_RADIUS_KM = 6371.01; -const double GeoUtils::MIN_LATITUDE_RADIANS = - TWO_PI; -const double GeoUtils::MAX_LATITUDE_RADIANS = TWO_PI; -const double GeoUtils::MIN_LATITUDE_DEGREES = GeoUtils::MIN_LATITUDE_RADIANS * RAD_TO_DEG; -const double GeoUtils::MAX_LATITUDE_DEGREES = GeoUtils::MAX_LATITUDE_RADIANS * RAD_TO_DEG; -const double GeoUtils::MIN_LONGITUDE_RADIANS = - PI;; -const double GeoUtils::MAX_LONGITUDE_RADIANS = PI; -const double GeoUtils::MIN_LONGITUDE_DEGREES = GeoUtils::MIN_LONGITUDE_RADIANS * RAD_TO_DEG; -const double GeoUtils::MAX_LONGITUDE_DEGREES = GeoUtils::MAX_LONGITUDE_RADIANS * RAD_TO_DEG; +const double Utils::EARTH_RADIUS_KM = 6371.01; +const double Utils::MIN_LATITUDE_RADIANS = - TWO_PI; +const double Utils::MAX_LATITUDE_RADIANS = TWO_PI; +const double Utils::MIN_LATITUDE_DEGREES = Utils::MIN_LATITUDE_RADIANS * RAD_TO_DEG; +const double Utils::MAX_LATITUDE_DEGREES = Utils::MAX_LATITUDE_RADIANS * RAD_TO_DEG; +const double Utils::MIN_LONGITUDE_RADIANS = - PI;; +const double Utils::MAX_LONGITUDE_RADIANS = PI; +const double Utils::MIN_LONGITUDE_DEGREES = Utils::MIN_LONGITUDE_RADIANS * RAD_TO_DEG; +const double Utils::MAX_LONGITUDE_DEGREES = Utils::MAX_LONGITUDE_RADIANS * RAD_TO_DEG; -std::vector GeoUtils::decodeGeoPolyline(const std::string& encodedGeoPolyline) +std::vector Utils::decodeGeoPolyline(const std::string& encodedGeoPolyline) { std::vector polyline; @@ -97,7 +97,7 @@ std::vector GeoUtils::decodeGeoPolyline(const std::string& encodedGe } -double GeoUtils::distanceSpherical(const Coordinate& coordinate0, +double Utils::distanceSpherical(const Coordinate& coordinate0, const Coordinate& coordinate1) { double lat0 = coordinate0.getLatitudeRad(); @@ -113,7 +113,7 @@ double GeoUtils::distanceSpherical(const Coordinate& coordinate0, } -double GeoUtils::distanceHaversine(const Coordinate& coordinate0, +double Utils::distanceHaversine(const Coordinate& coordinate0, const Coordinate& coordinate1) { // reference: http://www.movable-type.co.uk/scripts/latlong.html @@ -135,7 +135,7 @@ double GeoUtils::distanceHaversine(const Coordinate& coordinate0, } -double GeoUtils::bearingHaversine(const Coordinate& coordinate0, +double Utils::bearingHaversine(const Coordinate& coordinate0, const Coordinate& coordinate1) { // reference: http://www.movable-type.co.uk/scripts/latlong.html @@ -154,7 +154,7 @@ double GeoUtils::bearingHaversine(const Coordinate& coordinate0, } -Coordinate GeoUtils::midpoint(const Coordinate& coordinate0, +Coordinate Utils::midpoint(const Coordinate& coordinate0, const Coordinate& coordinate1) { // reference: http://www.movable-type.co.uk/scripts/latlong.html @@ -182,7 +182,7 @@ Coordinate GeoUtils::midpoint(const Coordinate& coordinate0, } -UTMLocation GeoUtils::toUTM(const Coordinate& coordinate) +UTMLocation Utils::toUTM(const Coordinate& coordinate) { double northing; double easting; @@ -201,7 +201,7 @@ UTMLocation GeoUtils::toUTM(const Coordinate& coordinate) } -Coordinate GeoUtils::toCoordinate(const UTMLocation& location) +Coordinate Utils::toCoordinate(const UTMLocation& location) { double latitude = 0; double longitude = 0; @@ -216,26 +216,26 @@ Coordinate GeoUtils::toCoordinate(const UTMLocation& location) } -Coordinate GeoUtils::randomCoordinate() +Coordinate Utils::randomCoordinate() { return Coordinate(ofRandom(MIN_LATITUDE_DEGREES, MAX_LATITUDE_DEGREES), ofRandom(MIN_LONGITUDE_DEGREES, MAX_LONGITUDE_DEGREES)); } -UTMLocation GeoUtils::randomUTMLocation() +UTMLocation Utils::randomUTMLocation() { return toUTM(randomCoordinate()); } -ofVec2d GeoUtils::toVec(const UTMLocation& location) +ofVec2d Utils::toVec(const UTMLocation& location) { return ofVec2d(location.getEasting(), location.getNorthing()); } -ofVec2d GeoUtils::toVec(const Coordinate& coordinate) +ofVec2d Utils::toVec(const Coordinate& coordinate) { return toVec(toUTM(coordinate)); } diff --git a/src/ofxGeo.h b/src/ofxGeo.h index b8d90da..159571b 100644 --- a/src/ofxGeo.h +++ b/src/ofxGeo.h @@ -30,9 +30,10 @@ #include "ofVec3d.h" #include "ofVec4d.h" #include "ofRectangled.h" - -#include "ofxSpatialHash.h" +#include "UTM/UTM.h" #include "ofx/Geo/Coordinate.h" #include "ofx/Geo/UTMLocation.h" -#include "ofx/Geo/GeoUtils.h" -#include "UTM/UTM.h" +#include "ofx/Geo/Utils.h" + + +namespace ofxGeo = ofx::Geo;