Skip to content

Commit

Permalink
Massive updates, removed ofxSpatialHash support, updated Readme, clea…
Browse files Browse the repository at this point in the history
…ned up examples.
  • Loading branch information
bakercp committed Apr 15, 2016
1 parent 6e30dbc commit 1cb6610
Show file tree
Hide file tree
Showing 30 changed files with 117 additions and 129 deletions.
7 changes: 6 additions & 1 deletion README.md
Expand Up @@ -3,4 +3,9 @@ ofxGeo

A set of utilities and classes for common geographic tasks.

Also includes Geographic Lib http://geographiclib.sourceforge.net/html/
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
4 changes: 0 additions & 4 deletions addon_config.mk
Expand Up @@ -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
2 changes: 1 addition & 1 deletion example_earth/Makefile
Expand Up @@ -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!
Expand Down
1 change: 0 additions & 1 deletion example_earth/addons.make
@@ -1,4 +1,3 @@
ofxGeo
ofxSatellite
ofxSpatialHash
ofxTime
4 changes: 2 additions & 2 deletions example_earth/src/main.cpp
@@ -1,6 +1,6 @@
// =============================================================================
//
// Copyright (c) 2013 Christopher Baker <http://christopherbaker.net>
// Copyright (c) 2013-2016 Christopher Baker <http://christopherbaker.net>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -29,5 +29,5 @@
int main()
{
ofSetupOpenGL(1024, 768, OF_WINDOW);
ofRunApp(new ofApp());
ofRunApp(std::make_shared<ofApp>());
}
24 changes: 12 additions & 12 deletions example_earth/src/ofApp.cpp
@@ -1,6 +1,6 @@
// =============================================================================
//
// Copyright (c) 2010-2014 Christopher Baker <http://christopherbaker.net>
// Copyright (c) 2010-2016 Christopher Baker <http://christopherbaker.net>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -77,26 +77,26 @@ 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
ofVec3f worldPoint = latRot * longRot * spinQuat * center;

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);

Expand Down
9 changes: 3 additions & 6 deletions example_earth/src/ofApp.h
@@ -1,6 +1,6 @@
// =============================================================================
//
// Copyright (c) 2013 Christopher Baker <http://christopherbaker.net>
// Copyright (c) 2013-2016 Christopher Baker <http://christopherbaker.net>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -30,9 +30,6 @@
#include "ofxSatellite.h"


using namespace ofx;


class ofApp: public ofBaseApp
{
public:
Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion example_geographclib/Makefile
Expand Up @@ -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!
Expand Down
1 change: 0 additions & 1 deletion example_geographclib/addons.make
@@ -1,2 +1 @@
ofxGeo
ofxSpatialHash
4 changes: 2 additions & 2 deletions example_geographclib/src/main.cpp
@@ -1,6 +1,6 @@
// =============================================================================
//
// Copyright (c) 2014 Christopher Baker <http://christopherbaker.net>
// Copyright (c) 2014-2016 Christopher Baker <http://christopherbaker.net>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -29,5 +29,5 @@
int main()
{
ofSetupOpenGL(520, 94, OF_WINDOW);
ofRunApp(new ofApp());
ofRunApp(std::make_shared<ofApp>());
}
39 changes: 19 additions & 20 deletions example_geographclib/src/ofApp.cpp
@@ -1,6 +1,6 @@
// =============================================================================
//
// Copyright (c) 2014 Christopher Baker <http://christopherbaker.net>
// Copyright (c) 2014-2016 Christopher Baker <http://christopherbaker.net>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -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;
}

}
Expand All @@ -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;
Expand Down
11 changes: 4 additions & 7 deletions example_geographclib/src/ofApp.h
@@ -1,6 +1,6 @@
// =============================================================================
//
// Copyright (c) 2014 Christopher Baker <http://christopherbaker.net>
// Copyright (c) 2014-2016 Christopher Baker <http://christopherbaker.net>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -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;

};
2 changes: 1 addition & 1 deletion example_measurement/Makefile
Expand Up @@ -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!
Expand Down
1 change: 0 additions & 1 deletion example_measurement/addons.make
@@ -1,2 +1 @@
ofxGeo
ofxSpatialHash
4 changes: 2 additions & 2 deletions example_measurement/src/main.cpp
@@ -1,6 +1,6 @@
// =============================================================================
//
// Copyright (c) 2014 Christopher Baker <http://christopherbaker.net>
// Copyright (c) 2014-2016 Christopher Baker <http://christopherbaker.net>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -29,5 +29,5 @@
int main()
{
ofSetupOpenGL(520, 94, OF_WINDOW);
ofRunApp(new ofApp());
ofRunApp(std::make_shared<ofApp>());
}
18 changes: 9 additions & 9 deletions example_measurement/src/ofApp.cpp
@@ -1,6 +1,6 @@
// =============================================================================
//
// Copyright (c) 2014 Christopher Baker <http://christopherbaker.net>
// Copyright (c) 2014-2016 Christopher Baker <http://christopherbaker.net>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -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);
}


Expand All @@ -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;
Expand Down
17 changes: 7 additions & 10 deletions example_measurement/src/ofApp.h
@@ -1,6 +1,6 @@
// =============================================================================
//
// Copyright (c) 2014 Christopher Baker <http://christopherbaker.net>
// Copyright (c) 2014-2016 Christopher Baker <http://christopherbaker.net>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -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;

};
2 changes: 1 addition & 1 deletion example_polyline/Makefile
Expand Up @@ -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!
Expand Down
1 change: 0 additions & 1 deletion example_polyline/addons.make
@@ -1,2 +1 @@
ofxGeo
ofxSpatialHash

0 comments on commit 1cb6610

Please sign in to comment.