diff --git a/.travis.yml b/.travis.yml index 26215d6..2b3f5ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,7 @@ language: java +branches: + only: + - master jdk: - oraclejdk8 - oraclejdk7 diff --git a/README.md b/README.md index 2aa4e20..1bbec33 100644 --- a/README.md +++ b/README.md @@ -50,17 +50,17 @@ Before building the Java bindings, you must install the libpostal C library. Mak **On Ubuntu/Debian** ``` -sudo apt-get install curl libsnappy-dev autoconf automake libtool pkg-config +sudo apt-get install curl autoconf automake libtool pkg-config ``` **On CentOS/RHEL** ``` -sudo yum install snappy snappy-devel autoconf automake libtool pkgconfig +sudo yum install curl autoconf automake libtool pkgconfig ``` **On Mac OSX** ``` -sudo brew install snappy autoconf automake libtool pkg-config +sudo brew install curl autoconf automake libtool pkg-config ``` **Installing libpostal** @@ -92,6 +92,13 @@ This will implicitly run [build.sh](./build.sh) which automatically runs the Aut On RHEL it might be necessary to set ```PKG_CONFIG_PATH=/usr/lib/pkgconfig``` before running the gradle build. +Usage in a Java project +----------------------- + +The JNI portion of jpostal builds shared object files (.so on Linux, .jniLib on Mac) that need to be on java.library.path. After running ```gradle assemble``` the .so/.jniLib files can be found under ```src/main/jniLibs``` in the checkout dir. For running the tests, we set java.library.path explicitly [here](https://github.com/openvenues/jpostal/blob/master/build.gradle#L18). + +For gradle users, there's a plugin called gradle-natives that may be helpful: https://github.com/cjstehno/coffeaelectronica/wiki/Going-Native-with-Gradle + Compatibility ------------- diff --git a/src/main/c/jpostal_AddressExpander.c b/src/main/c/jpostal_AddressExpander.c index 50a20a0..8e052c7 100644 --- a/src/main/c/jpostal_AddressExpander.c +++ b/src/main/c/jpostal_AddressExpander.c @@ -30,7 +30,7 @@ JNIEXPORT jobjectArray JNICALL Java_com_mapzen_jpostal_AddressExpander_libpostal const char *address = (*env)->GetStringUTFChars(env, jAddress, 0); size_t num_expansions = 0; - normalize_options_t options = get_libpostal_default_options(); + libpostal_normalize_options_t options = libpostal_get_default_options(); jfieldID fid; @@ -208,7 +208,7 @@ JNIEXPORT jobjectArray JNICALL Java_com_mapzen_jpostal_AddressExpander_libpostal options.roman_numerals = (*env)->GetBooleanField(env, jOptions, fid); - char **expansions = expand_address((char *)address, options, &num_expansions); + char **expansions = libpostal_expand_address((char *)address, options, &num_expansions); (*env)->ReleaseStringUTFChars(env, jAddress, address); @@ -225,7 +225,7 @@ JNIEXPORT jobjectArray JNICALL Java_com_mapzen_jpostal_AddressExpander_libpostal } if (expansions != NULL) { - expansion_array_destroy(expansions, num_expansions); + libpostal_expansion_array_destroy(expansions, num_expansions); } if (languages != NULL) { @@ -250,7 +250,7 @@ JNIEXPORT void JNICALL Java_com_mapzen_jpostal_ExpanderOptions_00024Builder_setD jfieldID fid; jclass cls = (*env)->GetObjectClass(env, builder); - normalize_options_t default_options = get_libpostal_default_options(); + libpostal_normalize_options_t default_options = libpostal_get_default_options(); fid = (*env)->GetFieldID(env, cls, "languages", "[Ljava/lang/String;"); if (fid == 0) { diff --git a/src/main/c/jpostal_AddressParser.c b/src/main/c/jpostal_AddressParser.c index 959374e..8ecb7bc 100644 --- a/src/main/c/jpostal_AddressParser.c +++ b/src/main/c/jpostal_AddressParser.c @@ -28,7 +28,7 @@ JNIEXPORT jobjectArray JNICALL Java_com_mapzen_jpostal_AddressParser_libpostalPa const char *address = (*env)->GetStringUTFChars(env, jAddress, 0); - address_parser_options_t options = get_libpostal_address_parser_default_options(); + libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options(); jfieldID fid; @@ -56,7 +56,7 @@ JNIEXPORT jobjectArray JNICALL Java_com_mapzen_jpostal_AddressParser_libpostalPa options.country = (char *)(*env)->GetStringUTFChars(env, jCountry, 0); } - address_parser_response_t *response = parse_address((char *)address, options); + libpostal_address_parser_response_t *response = libpostal_parse_address((char *)address, options); (*env)->ReleaseStringUTFChars(env, jAddress, address); @@ -92,7 +92,7 @@ JNIEXPORT jobjectArray JNICALL Java_com_mapzen_jpostal_AddressParser_libpostalPa } if (response != NULL) { - address_parser_response_destroy(response); + libpostal_address_parser_response_destroy(response); } return ret; @@ -112,7 +112,7 @@ JNIEXPORT void JNICALL Java_com_mapzen_jpostal_ParserOptions_00024Builder_setDef jfieldID fid; jclass cls = (*env)->GetObjectClass(env, builder); - address_parser_options_t default_options = get_libpostal_address_parser_default_options(); + libpostal_address_parser_options_t default_options = libpostal_get_address_parser_default_options(); fid = (*env)->GetFieldID(env, cls, "language", "Ljava/lang/String;"); if (fid == 0) { diff --git a/src/test/java/com/mapzen/jpostal/TestAddressParser.java b/src/test/java/com/mapzen/jpostal/TestAddressParser.java index 49a248b..9c7dcb6 100644 --- a/src/test/java/com/mapzen/jpostal/TestAddressParser.java +++ b/src/test/java/com/mapzen/jpostal/TestAddressParser.java @@ -55,33 +55,5 @@ public void testParseUSAddress() { new ParsedComponent("11216", "postcode"), new ParsedComponent("usa", "country") ); - - testParse("whole foods ny", - new ParsedComponent("whole foods", "house"), - new ParsedComponent("ny", "state") - ); - - testParse("1917/2 Pike Drive", - new ParsedComponent("1917 / 2", "house_number"), - new ParsedComponent("pike drive", "road") - ); - - testParse("3437 warwickshire rd,pa", - new ParsedComponent("3437", "house_number"), - new ParsedComponent("warwickshire rd", "road"), - new ParsedComponent("pa", "state") - ); - - testParse("3437 warwickshire rd, pa", - new ParsedComponent("3437", "house_number"), - new ParsedComponent("warwickshire rd", "road"), - new ParsedComponent("pa", "state") - ); - - testParse("3437 warwickshire rd pa", - new ParsedComponent("3437", "house_number"), - new ParsedComponent("warwickshire rd", "road"), - new ParsedComponent("pa", "state") - ); } } \ No newline at end of file