Code Monkey home page Code Monkey logo

osmapi-java's Introduction

About

OSMAPI Java is a java library to interact with OpenStreetMap based data. It includes fast address searching, reverse geocoding, routing and OSM data manipulation.

The API may be used in java applications as well as with Android apps.

Usage

To find matching addresses starting with "wars" use:

SearchAPIQuery query = QueryFactory.createSearchQuery("wars");
SearchAPIPlace[] results = searchAPI.findAddress(query);

To find a route between two places use:

RoutingAPIQuery query = QueryFactory.createRoutingQuery(52.8709827, 20.6171934, 52.5354061, 19.715046);
RoutingAPIPath path = routingAPI.findPath(query, Locale.getDefault());

To find a place matching given location use:

PlacesAPIQuery query = QueryFactory.createPlacesQuery(53.22054,21.87315);
FeatureCollection results = placesAPI.queryPlace(query);

To get all places in given bounding box use:

PlacesAPIQuery query = QueryFactory.createPlacesQuery(52.22733,21.00427, 52.22815,21.00539);
FeatureCollection results = placesAPI.queryPlace(query);

To get an image for a place use:

PlacesAPIQuery query = QueryFactory.createPlacesQuery(53.22054,21.87315);
FeatureCollection results = placesAPI.queryPlace(query);
FeatureImage image = placesAPI.imageForFeature(results.getFeatures()[0]);

To work with OSM nodes in OSM database use:

// get node
OSMNode result = osmElementAPI.getNode(803223);
(...)

// create node
OSMNode node = new OSMNode();
node.setLon(23.50);
node.setLat(53.21);
node.setVisible(true);
OSMNode result = osmElementAPI.createNode(node, "adding node", osmCredentials);

// modify node (be carefull !)
OSMNode result = osmElementAPI.getNode(803223);
(... change node properties ...)		
OSMNode updatedNode = osmElementAPI.updateNode(result,"updating node", osmCredentials);

Documentation

See the Wiki's API documentation

#Java installation Please download java-osmapi-1.0.0-RELEASE.jar into your project libs folder and add following pom dependencies:

		<dependency>
			<groupId>org.apache.httpcomponents</groupId>
			<artifactId>httpclient</artifactId>
			<version>${httpclient.version}</version>
		</dependency>
		
		<dependency>
			<groupId>com.google.code.gson</groupId>
			<artifactId>gson</artifactId>
			<version>${gson.version}</version>
		</dependency>
		
		<dependency>
			<groupId>org.simpleframework</groupId>
			<artifactId>simple-xml</artifactId>
			<version>${simplexml.version}</version>
		</dependency>
	

Android installation

For use with Android based apps please download [java-osmapi-1.0.0-RELEASE.jar] (https://github.com/osmapi/osmapi-java/releases/download/v1.0.1/java-osmapi-1.0.0-RELEASE.jar) into your project libs folder and add following Gradle dependencies:

	compile 'com.google.code.gson:gson:2.3.1'
    compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
    compile('org.simpleframework:simple-xml:2.7.+'){
        exclude module: 'stax'
        exclude module: 'stax-api'
        exclude module: 'xpp3'
    }

Maven

Coming soon - we are working on putting osmapi-java into Maven Central repository.

osmapi-java's People

Contributors

osmapi avatar wolfgangfahl avatar alkeicam avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.