This project is now archived. Note: The active fork of this project is https://github.com/fdrusso/geosense
GeoSense is a self-contained package that gives a Java application a sense of locality for any location, not just the server on which the code is running. As of the current version, 'locality' is based mainly around time zone - how can you be local if you don't even know what time it is?
But rich data does exist around time zones, namely the public-domain TZ database (http://en.wikipedia.org/wiki/Tz_database) and an excellent shapefile with polygon boundaries for timezones from this database (http://efele.net/maps/tz/world/). GeoSense was built to take advantage of these data sources to provide low-overhead lookup of time zone by arbitrary (lat,lon) coordinates, and then use this information to connect to other localization-relevant information such as country, locale, currency, etc.
Equally important is that the resulting jar is self-contained: all functionality is accessible via direct method calls (no external services involved). When an application includes a maven dependency on geosense, it brings in zero transitive dependencies. And initialization is automatic on loading the class. So usage consists of importing com.redlaser.geosense.GeoSense, then calling one of its available methods. Examples include:
TimeZone tz1 = GeoSense.getTimeZone(37.29390,-121.91413); // returns America/Los_Angeles String country1 = GeoSense.getACountry(tz1); // returns "US" List<TimeZone> tzs1 = GeoSense.getTimeZones("US"); // returns 30 timezones (!) List<TimeZone> tzs2 = GeoSense.getTimeZones("DE"); // returns 1 timezone TimeZone tz2 = GeoSense.getATimeZone("DE"); // returns Europe/Berlin
This distribution incorporates data from the following 3rd-party sources:
zone.tab (public domain, see http://en.wikipedia.org/wiki/Tz_database)
see NOTICE.txt for details
Copyright (c) 2013 eBay Software Foundation
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.