Git Product home page Git Product logo

text-instructions's Introduction

OSRM Text Instructions - Java J2V8 Wrapper

Build Status Maven Central

This library wraps javascript functions from the OSRM Text Instructions library that is programmed in javascript as a java project. The osrm-text-instructions library uses the MapBox LegStep to model the routes and compiles human readable instructions on how to follow the next direction on a route. I had the need and idea to port the node module by running a V8 instance on the JVM using the wonderful J2V8 library and allowing direct calls to the main javascript library from Java. This will make keeping up the development simple as new functionality arises.

Some example uses

try (OSRMTextInstructions textInstructions = new OSRMTextInstructions(VERSION)) {
	String wayName = "Route 66";
	StepManeuver maneuver = new StepManeuver("turn", "left", 1);
	LegStep step = new LegStep();
	
	step.setManeuver(maneuver);
	step.setName(wayName);
			
	assertEquals("Turn left onto Route 66", textInstructions.compile("en", step, null));
	assertEquals("Gire a la izquierda en Route 66", textInstructions.compile("es", step, null));
	assertEquals("Svolta a sinistra in Route 66", textInstructions.compile("it", step, null));
	assertEquals("Ga linksaf naar Route 66", textInstructions.compile("nl", step, null));
	assertEquals("左转,上Route 66", textInstructions.compile("zh-Hans", step, null));
}

Available on the central maven repository

This library is available on the central repository. My versioning will match the OSRM Text Instruction projects and will have the maven dependency tags for the pom included on the release page. I will stay posted when a version has updated and keep up with original library as quickly as I can.

Rolling your own version

I have pre-installed the node modules in the resource folders to avoid the user needing to install node.js or npm. If, however, you want the latest version you will need to go to osrm-text-instruction release page and download the version you like as a zip file and add it to src/main/resources/node_modules. You'll then need ot update OSRMTextInstructions.MODULE_VERSION to the verison that you have added. At this point you must verify that any new or changed methods in install.js are wrapped correctly in OSRMTextInstructions.java. If you don't want to do this just wait a few days and i'll add the latest version.

FYI

The MapBox LegStep model supplements the OSRM RouteStep object required in the compile steps. While a java version has already been created, it doesn't seem to be maintained currently to keep it up to date with the main project but I have drawn on some of its setup for my own project. However it does have an android/gradle setup which may be useful for someone developing on Android.

text-instructions's People

Contributors

bitsondatadev avatar

Watchers

Rohan 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.