1 / 18

SimpleGeo

SimpleGeo. Temporal and Spatial Information. Information can have temporal and spatial aspects Examples Directions can be thought of as: Given that I’m here now, what do I do next?

sema
Download Presentation

SimpleGeo

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SimpleGeo

  2. Temporal and Spatial Information • Information can have temporal and spatial aspects • Examples • Directions can be thought of as: Given that I’m here now, what do I do next? • You are at an office door, the person is out. We can represent the information that the person in this office is out until 1pm • The building to the west is Gore Hall • The history of here (where here is where you are) • Self guided tour • Local news • Nearest party (at this moment, or planned in the future) • Found art/found sound • Music composers use found sound in their compositions. Examples include John Cage, Nicolas Collins, Art of Noise, The Slant (band), Robin Rimbaud AKA Scanner and The Books. – wikipedia “found art” • Joe frank • Law enforcement / military intelligence • A bad guy lives in that house, but is at his mother’s on Sundays, and today is Sunday. • More? • Information can be relevant only when you are at the location, when you are planning to go to the location, or for browsing • Browsing e.g., getting information about what is going on at different places throughout a city

  3. SimpleGeo Cloud • Stores data that is associated with location information. This data is stored in (distributed) servers, and hence can be updated and retrieve from any phone. That is, the data is stored in the cloud. • Products • SimpleGeo Places is a free database of business listings and points of interest (POIs) that enables real-time community collaboration. • This seems to be SimpleGeo’s main focus • SimpleGeo Storage is a unique, hosted non-relational geospatial database tuned specifically for querying and storing location data • SimpleGeo Context provides relevant contextual information such as geographic boundaries, weather, and demographics for a specific location. • Context is a great concept (more on context later and in Dr Loeb’s course), but since context includes everything, it is difficult to implement. Weather and demographics is a very narrow view of context. • SimpleGeo Places is design for business listing, but allows general data storage. In this way, SimpleGeo Places provides some of the features that SimpleGeo Storage does. • Early thoughts • I suspect that SimpleGeo’s real objective is to develop a data set that grows from user contribution. However, simple business listing (like yellow pages) is not enough, more intelligence (e.g., context, user preferences, opinions)

  4. Getting Set Up • Download Apache Ant • E.g., put it a subdirectory of eclipse • Get SimpleGeo software • Go to simpleGeo.com • Look for tools -> android. On GitHub page is “Download” button. • Save in eclipse/SimpleGeo • extract • Or using git (perferred approach) • Get a git client • E.g., smartGit: http://www.syntevo.com/smartgit/index.html • in your git client, clone https://github.com/simplegeo/java-simplegeo.git • Save to eclipse/SimpleGeo • Building libraries • Open command prompt • cd to eclipse/SimpleGeo • Run ant to make jar files, • c:\eclipse\simpleGeo> C:\eclipse\apache-ant-1.8.1\bin\ant.exe jar-with-libs • There are other options, such as places-jar-with-libs, if only places will be used and context is not used. Also, jar-without-libs, if you want to include the libraries from your own project. • Check that c:\eclipse\simpleGeo\bin\java-simplegeo-2.0.jar exists

  5. Get Places Around UD in java • Error message reporting is better in java than in Android, so it is better to try regular java first • In eclipse -> new java project • Named TestSimpleGeoDesktop • In src subdirectory, • right-click, new -> class • Name = TestSimpleGeoDesktop • Select public statis void main(String[] args) • Add simpleGeo lib • Right click on src subdirectory • Select build path -> configure build path • Select Libraries tab • Select add eternal JARs • Browse to c:\eclipse\simpleGeo\bin\java-simplegeo-2.0.jar (which you made with ant), select ok • Select Order and Export tab • Click java-simplegio-2.0.jar

  6. Add code • After public class TestSimpleGeoDesktop {, add • static SimpleGeoPlacesClientclient; • After public static void main(String[] args) {, add • client = SimpleGeoPlacesClient.getInstance(); • client.getHttpClient().setToken("v6twG2W4aHmXk725WryK22wUnXVSmhqT", "5wvfksDtH8QSMZeKKcDXaXC3HVDfJVx2"); • // this is my key and secret. You can get your own. But with this key+secret we can share data • Next add • client.search(39.680000, -75.751349, "", "", 1, new FeatureCollectionCallback() { }); • Let eclipse Import appropriate classes • Let eclipse add unimplemented methods • Let eclipse surround with try-catch • After public void onError(String arg0) {, add • System.out.println(arg0); • Replace e.printStackTrace(); with • System.out.println(e.getMessage());

  7. Change public void onSuccess(FeatureCollection arg0) { to public void onSuccess(FeatureCollection collection{ • After public void onSuccess(FeatureCollection collection{ add, ArrayList<Feature> features = collection.getFeatures(); System.out.println("number of features received "+features.size()); for (Feature feature : features) { System.out.println("feature type: "+feature.getType()); HashMaphm = feature.getProperties(); Set set = hm.entrySet(); Iteratori = set.iterator(); while(i.hasNext()){ Map.Entry me = (Map.Entry)i.next(); System.out.println(" "+me.getKey() + " : " + me.getValue() ); } } • Warning: be sure to import jave.XX classes • Run • Potential errors • I got an error saying that the crytpography scheme was not available. To fix this, I installed the latest version of jdk and jce.

  8. SimpleGeo data format • In SimpleGeo a feature is a place. And this place has information associated with it. This information might also have time associated with it • I.e., in theory, a single place can have multiple chunks of information, each with a different time • I haven’t tested this • Information has three parts, properties, geometry, and ID • Properties, retrieved from .getProperties(), returns a hashmap of string-object pairs • E.g • phone : +1 302 831 2421 • classifiers : [{"category":"Education","subcategory":"College","type":"Public Place"}] • address : 130 Academy St • name : University of Delaware • province : DE • owner : simplegeo • postcode : 19711 • href : http://api.simplegeo.com/1.0/features/SG_5sKEWyqNWL6zeUPPBoeUNY_39.680309_-75.749722@1294085537.json • city : Newark • country : US

  9. Note that classifiers is an object, which could contain more objects as members. • How to exchange objects when they might have slightly complicated structures • slightly complicated means that they don’t have loops • E.g., class A has members B and C and B has member A • JSON is a standard that converts objects into text and text into objects • JSON relies on the ability to convert strings, numbers, and booleans into string and from strings to strings, numbers, and booleans • SimpleGeo uses JSON to move data from cloud to the local host • See http://SimpleGeo.com -> documentation -> apiEndpoints (http://simplegeo.com/docs/api-endpoints) list of feature categories • To use SimpleGeo, you do not need to worry about JSON, unless you want to save complicated objects. Specifically, no need to think about JSON if you will just save simple pairs (e.g., name-string, name-number, name-boolean).

  10. SimpleGeo data • Information has three parts, properties, geometry, and ID • Geometry • Point: lat, long, nothing on altitude : ( • Polygon • Multipolygon • ID • SG_{unique_string}_{lat}_{lon}@{epoch} • E.g., the state of California is SG_2AziTafTLNReeHpRRkfipn_37.766713_-122.428938@1291796505 • Places can be retrieved by ID, but lat, lon, and epoch are not needed

  11. Android Program • Make new android app, called SimpleGeoTest • Add use internet permission • I forgot this and spent a long time debugging! • Add SimpleGeo jar • Add three buttons • Search • Set place • Search for my places • Delete my places

  12. Add member variable to SimpleGeoTest • SimpleGeoPlacesClient client; • After setContentView, add • Log.e("DEBUG INFO","setting up client"); • client = SimpleGeoPlacesClient.getInstance(); • client.getHttpClient().setToken("v6twG2W4aHmXk725WryK22wUnXVSmhqT", "5wvfksDtH8QSMZeKKcDXaXC3HVDfJVx2"); • Log.e("DEBUG INFO","client is set"); • Make call back for search • See your HelloWorld project for how to do this. • In onClick, add • Log.e("DebugInfo","Search been clicked"); • client.search(39.680000, -75.751349, "", "", 1, new FeatureCollectionCallback() { }); • Allow eclipse to import and add unimplemented methods • Cut code from the desktop version, but replace System.out.println, with Log.e(“DEBUG INFO”, • Run, press button, and see log

  13. A place of our own • Add callback listener for Set Place • Recall, a place has three things • Geometry • Point, or polygon • Properties • A list of string-value pairs • ID • SimpleGeo will determine the ID, we must set the rest • Plan: define feature, upload this feature • upload • See java docmentation: http://simplegeo.github.com/java-simplegeo/2.0/index • click com.simplegeo.client • Click SimpleGeoPlacesClient • We can use addPlace function to upload our feature • Define feature • Note that addPlace takes feature are an argument, click on feature • We will use • setGeometry • setProperties • After onClick, add • Feature myFeature = new Feature(); • myFeature.setType("feature"); • myFeature.setGeometry(new Geometry(new Point(39.680189, -75.751349))); • Warning: eclipse will ask to import android.point or simpleGeo…point. We want simpleGeo, but android point is needed for using maps. • Change the above to • myFeature.setGeometry(new Geometry(new com.simplegeo.client.types.Point(39.680189, -75.751349))); • Now we are explicit in which class we are using. • Define our properties • HashMaphm = new HashMap(); • hm.put("private",true); • hm.put("record_id", 1); • hm.put("address", "309 Evans Hall"); • hm.put("owner", "eleg454"); • hm.put("name", "eleg454: bohacek’s Lab"); // let’s always start name with eleg454 • hm.put("thought", "faster faster"); • // whatever else you want • Set the properties • myFeature.setProperties(hm);

  14. Upload our place • client.addPlace(myFeature,newSimpleGeoCallback<java.util.HashMap<java.lang.String,java.lang.Object>>() { } ); • Let eclipse import and add unimplemented classes • In onError, add • Log.e("DEBUG INFO","update error: "+arg0); • In onSuccess, add • if (arg0==null) { • Log.e("DEBUG INFO","success has arg==null"); • } else { • Set set = arg0.entrySet(); • Iteratori = set.iterator(); • while(i.hasNext()){ • Map.Entry me = (Map.Entry)i.next(); • Log.e("DEBUG INFO"," "+me.getKey() + " : " + me.getValue() ); • } • } • Let eclipse surround by try-catch • After } catch (IOException e) {, replace e.printStackTrace(); with • Log.e("DEBUG INFO","IO exception:" + e.getMessage()); • After } catch (JSONException e) {, replace e.printStackTrace(); with • Log.e("DEBUG INFO","JSON exception:" + e.getMessage()); • Run, press set set place, and examine output • ( Copy log to file: in DDMS highlight the rows of interest. In the upper right of logCat window, click on the down-arrow. “Select Export Text”) • Output • 02-24 19:52:57.073: INFO/SimpleGeoHandler(13890): received response org.apache.http.message.BasicHttpResponse@4495bb48 • 02-24 19:52:57.083: ERROR/DEBUG INFO(13890): id : SG_2GMYcSbpJ33WtmR0ewwZwr_39.680189_-75.751349@1298595176 • 02-24 19:52:57.083: ERROR/DEBUG INFO(13890): token : 95c4a6c2407911e0a73212313b0af8d7 • 02-24 19:52:57.083: ERROR/DEBUG INFO(13890): uri : http://api.simplegeo.com/1.0/features/SG_2GMYcSbpJ33WtmR0ewwZwr_39.680189_-75.751349@1298595176.json • We could use the id to retrieve this data chuck • The token is useless. I’m not sure what the uri could be used for • It is critical to check for errors when uploading. Sometimes I have gotten “gateway is busy error,” and onSuccess is triggered, but with arg=null. • In this case, we should try again.

  15. Spatial-temporal Information Retrieval • SimpleGeo provides simple searching • Search from point allows • Search term • E.g., starbuckss, returns records with name (or any entry) that includes starbucks • E.g., eleg454, returns recors with name eleg454, which are records we set • Category • Search for a type of place • Category has 3 (or 4) elements (see http://simplegeo.com/docs/api-endpoints/simplegeo-features#list-feature-categories) • A category search can search in any of these. • If both search term and category are defined, the results must satisfy both • Radius • Allows the distance from point to be set • Max number of entries is 25 • I’m not sure how these are ordered and how to get the next 25 • I think they are not ordered by distance • One can iteratively set the radius until less than 25 records are returned, but .. • Search from lat, lon • Same as search from point (not sure why both interfaces are supported. Maybe to allow more detailed point, e.g., point with altitude) • searchByAddress • Address is a street address such as 1600 Pennsylvania Ave NW, Washington D.C., DC • Other parameters are the same • searchByIP • Sometimes IP is related to location. However, the location information might be very coarse. The IP for you mobile phone does not change as you move • (MobileIP is a technique that allows your IP to stay the same even as you change ISP, e.g., if you move from one ISP (e.g., mobile phone provider) to another ISP (e.g., comcast via your home wifi) • Clearly, the search methods are very simple. Then again, so far, the information stored is fairly simple.

  16. Retrieve our places • add • final Button SearchForOurPlaces = (Button) findViewById(R.id.SearchForOurPlaces); • SearchForOurPlaces.setOnClickListener(new View.OnClickListener() {}); • After onClick, add • client.search(39.680000, -75.751349, “eleg454", "", 1, new FeatureCollectionCallback() {}); • This will search for any entry that has eleg454 somewhere in the record. • Let eclipse do its things, add Log.e message to onError • Change public void onSuccess(FeatureCollection arg0) {, to • public void onSuccess(FeatureCollection collection) { • After this, add • ArrayList<Feature> features = collection.getFeatures(); • Log.e("DEBUG INFO","number of features received "+features.size()); • for (Feature feature : features) { • Log.e("DEBUG INFO","feature type: "+feature.getType()); • HashMaphm = feature.getProperties(); • Set set = hm.entrySet(); • Iteratori = set.iterator(); • while(i.hasNext()){ • Map.Entry me = (Map.Entry)i.next(); • Log.e("DEBUG INFO"," "+me.getKey() + " : " + me.getValue() ); • } • }

  17. Delete our places • It is good to clean up after ourselves and delete everything we put in the cloud • First find our records, and delete one of them. • In DeleteOurPlaces button listener, add • client.search(39.680000, -75.751349, "eleg454", "", 1, new FeatureCollectionCallback() {}); • In onSucess, add • ArrayList<Feature> features = collection.getFeatures(); • if (features.size()==0) { • Log.e("Debug Info","nothing to delete"); • } else { • Log.e("Debug Info","num still to delete: "+features.size()); • client.deletePlace(features.get(0).getSimpleGeoId(), new SimpleGeoCallback<java.util.HashMap<java.lang.String,java.lang.Object>> () {}); • Let eclipse add things and you add Log.e so we know what is going on.

  18. Reconsider spatial information ideas • Later we will add video and audio • However, we cannot put the video on SimpleGeo, we can only put the link on SimpleGeo • We are not using SimpleGeo correctly. • We are storing our own special information that only we understand • SimpleGeo would like their cloud to be a place for information that anyone can use. • This crowd-sourcing aspect of simpleGeo is critical for their success • Otherwise they are a simple database/cloud and are competing with amazon etc., which is not a great business plan. • SimpleGeo is very new, they came online december 2010. Certainly new things will come up.

More Related