Merge branch 'master' into 1940-user-location-in-sdk

This commit is contained in:
Brad Leege
2015-08-05 15:52:53 -05:00
78 changed files with 1033 additions and 1035 deletions

2
.gitignore vendored
View File

@@ -17,6 +17,8 @@
/ios/build
/ios/app/build
/test/build
/gyp/build
/gyp/java
/test/node_modules
/test/fixtures/*/*_actual.*
/test/fixtures/api/1.png

2
.mason

Submodule .mason updated: abdc131273...1d5789dfad

278
Makefile
View File

@@ -1,225 +1,101 @@
BUILDTYPE ?= Release
PYTHON ?= python
PREFIX ?= /usr/local
ANDROID_ABI ?= arm-v7
export BUILDTYPE ?= Release
export BUILD_TEST ?= 1
export BUILD_RENDER ?= 1
# Determine build platform
ifeq ($(shell uname -s), Darwin)
HOST = osx
HEADLESS = cgl
JOBS ?= $(shell sysctl -n hw.ncpu)
endif
ifeq ($(shell uname -s), Linux)
HOST = linux
JOBS ?= $(shell grep --count processor /proc/cpuinfo)
BUILD_ROOT = $(shell pwd)
endif
JOBS ?= 1
all: mbgl
include config/defaults.mk
#### Dependencies ##############################################################
# Wildcard targets get removed after build by default, but we want to preserve the config.
.PRECIOUS: config/%.gypi
config/%.gypi: CMD = ./configure config/$*.gypi
config/%.gypi: configure
@$(ENV_$*) ./scripts/flock.py build/Configure.lock ./configure config/$*.gypi
styles/styles:
git submodule update --init styles
ifeq ($(shell uname -s), Darwin)
SMCalloutView:
git submodule update --init platform/ios/vendor/SMCalloutView
export BUILD = osx
export JOBS ?= $(shell sysctl -n hw.ncpu)
export XCPRETTY := $(shell ./scripts/xcpretty.sh)
else ifeq ($(shell uname -s), Linux)
export BUILD = linux
export JOBS ?= $(shell grep --count processor /proc/cpuinfo)
else
SMCalloutView:
$(error Cannot determine build platform)
endif
export BUILD_VERSION = $(shell uname -m)
RUN = @$(MAKE) -f scripts/main.mk
default: ; @printf "You must specify a valid target\n"
#### OS X targets ##############################################################
ifeq ($(BUILD),osx)
.PHONY: osx xosx run-osx run-xosx
osx: ; $(RUN) HOST=osx HOST_VERSION=x86_64 Makefile/osxapp
xosx: ; $(RUN) HOST=osx HOST_VERSION=x86_64 Xcode/osxapp
run-osx: osx ; @"build/osx-x86_64/$(BUILDTYPE)/Mapbox GL.app/Contents/MacOS/Mapbox GL"
run-xosx: xosx ; @"gyp/build/$(BUILDTYPE)/Mapbox GL.app/Contents/MacOS/Mapbox GL"
.PHONY: Xcode/osx Xcode/ios
Xcode/ios: ; $(RUN) HOST=ios Xcode/__project__
Xcode/osx: ; $(RUN) HOST=osx HOST_VERSION=x86_64 Xcode/__project__
.PHONY: xproj iproj
xproj: Xcode/osx ; @open ./build/osx-x86_64/gyp/osx.xcodeproj
iproj: Xcode/ios ; @open ./build/ios-all/gyp/ios.xcodeproj
.PHONY: ios ibench isim
ios ibench isim: export XCODEBUILD_ARGS += PROVISIONING_PROFILE="$$(PROVISIONING_PROFILE)"
ios: export XCODEBUILD_ARGS += -sdk iphoneos ARCHS="arm64 armv7 armv7s"
ios: ; $(RUN) HOST=ios Xcode/iosapp
isim: export XCODEBUILD_ARGS += -sdk iphonesimulator ARCHS="x86_64 i386"
isim: ; $(RUN) HOST=ios Xcode/iosapp
ibench: export XCODEBUILD_ARGS += -sdk iphoneos ARCHS="arm64"
ibench: ; $(RUN) HOST=ios Xcode/ios-bench
.PHONY: ipackage ipackage-strip ipackage-sim itest
ipackage: Xcode/ios ; @JOBS=$(JOBS) ./scripts/ios/package.sh
ipackage-strip: Xcode/ios ; @JOBS=$(JOBS) ./scripts/ios/package.sh strip
ipackage-sim: Xcode/ios ; @JOBS=$(JOBS) ./scripts/ios/package.sh sim
itest: ipackage-sim ; ./scripts/ios/test.sh
endif
geojsonvt:
git submodule update --init src/mbgl/util/geojsonvt
#### All platforms targets #####################################################
KIF:
git submodule update --init test/ios/KIF
#### Build files ###############################################################
.PRECIOUS: Makefile/project
Makefile/project: config/$(HOST).gypi styles/styles SMCalloutView geojsonvt
deps/run_gyp gyp/$(HOST).gyp $(CONFIG_$(HOST)) $(LIBS_$(HOST)) --generator-output=./build/$(HOST) -f make
.PRECIOUS: Xcode/project
Xcode/project: config/$(HOST).gypi styles/styles SMCalloutView geojsonvt
deps/run_gyp gyp/$(HOST).gyp $(CONFIG_$(HOST)) $(LIBS_$(HOST)) --generator-output=./build/$(HOST) -f xcode
#### Library builds ############################################################
mbgl: Makefile/project
$(MAKE) -C build/$(HOST) BUILDTYPE=$(BUILDTYPE) everything
standalone: Makefile/project
LINK=`pwd`/gyp/link.py $(MAKE) -C build/$(HOST) BUILDTYPE=$(BUILDTYPE) standalone
install: Makefile/project
LINK=`pwd`/gyp/link.py $(MAKE) -C build/$(HOST) BUILDTYPE=$(BUILDTYPE) install
##### Test builds ##############################################################
.PHONY: test
test: Makefile/project
$(MAKE) -C build/$(HOST) BUILDTYPE=$(BUILDTYPE) test
test-%: test
./scripts/run_tests.sh "build/$(HOST)/$(BUILDTYPE)/test" --gtest_filter=$*
.PHONY: xtest
xtest: XCPRETTY := $(shell ./scripts/xcpretty.sh)
xtest: Xcode/project
xcodebuild -project ./build/osx/gyp/osx.xcodeproj -configuration $(BUILDTYPE) -target test -jobs $(JOBS) $(XCPRETTY)
xtest-%: xtest
./scripts/run_tests.sh "build/osx/Build/Products/$(BUILDTYPE)/test" --gtest_filter=$*
#### Mac OS X application builds ###############################################
.PHONY: osx run-osx
osx: Makefile/project
$(MAKE) -C build/osx BUILDTYPE=$(BUILDTYPE) osxapp
run-osx: osx
"build/osx/$(BUILDTYPE)/Mapbox GL.app/Contents/MacOS/Mapbox GL"
run-valgrind-osx: osx
(valgrind --leak-check=full --suppressions=scripts/valgrind.sup build/osx/$(BUILDTYPE)/Mapbox\ GL.app/Contents/MacOS/Mapbox\ GL)
.PHONY: xosx-proj xosx run-xosx
xosx-proj: Xcode/project
open ./build/osx/gyp/osx.xcodeproj
xosx: XCPRETTY := $(shell ./scripts/xcpretty.sh)
xosx: Xcode/project
xcodebuild -project ./build/osx/gyp/osx.xcodeproj -configuration $(BUILDTYPE) -target osxapp -jobs $(JOBS) $(XCPRETTY)
run-xosx: xosx
"gyp/build/$(BUILDTYPE)/Mapbox GL.app/Contents/MacOS/Mapbox GL"
# Legacy name
xproj: xosx-proj
#### iOS application builds ####################################################
.PRECIOUS: Xcode/ios
Xcode/ios: gyp/ios.gyp config/ios.gypi styles/styles SMCalloutView geojsonvt
deps/run_gyp gyp/ios.gyp $(CONFIG_ios) $(LIBS_ios) --generator-output=./build/ios -f xcode
.PHONY: ios-proj ios isim ipackage
ios-proj: Xcode/ios
open ./build/ios/gyp/ios.xcodeproj
ios: XCPRETTY := $(shell ./scripts/xcpretty.sh)
ios: Xcode/ios
xcodebuild -sdk iphoneos ARCHS="arm64 armv7 armv7s" PROVISIONING_PROFILE="19324a54-7455-4f0b-8e1c-e6957c718ebc" -project ./build/ios/gyp/ios.xcodeproj -configuration Release -target iosapp -jobs $(JOBS) $(XCPRETTY)
ibench: XCPRETTY := $(shell ./scripts/xcpretty.sh)
ibench: Xcode/ios
xcodebuild -sdk iphoneos ARCHS="arm64" PROVISIONING_PROFILE="19324a54-7455-4f0b-8e1c-e6957c718ebc" -project ./build/ios/gyp/ios.xcodeproj -configuration Release -target ios-bench -jobs $(JOBS) $(XCPRETTY)
isim: XCPRETTY := $(shell ./scripts/xcpretty.sh)
isim: Xcode/ios
xcodebuild -sdk iphonesimulator ARCHS="x86_64 i386" -project ./build/ios/gyp/ios.xcodeproj -configuration Debug -target iosapp -jobs $(JOBS) $(XCPRETTY)
ipackage: Xcode/ios
JOBS=$(JOBS) ./scripts/ios/package.sh
ipackage-strip: Xcode/ios
JOBS=$(JOBS) ./scripts/ios/package.sh strip
ipackage-sim: Xcode/ios
JOBS=$(JOBS) ./scripts/ios/package.sh sim
itest: ipackage-sim KIF
./scripts/ios/test.sh
# Legacy name
iproj: ios-proj
#### Linux application builds ##################################################
.PHONY: linux run-linux
linux: Makefile/project
$(MAKE) -C build/$(HOST) BUILDTYPE=$(BUILDTYPE) linuxapp
run-linux: linux
(cd build/$(HOST)/$(BUILDTYPE) && ./mapbox-gl)
run-valgrind-linux: linux
(cd build/$(HOST)/$(BUILDTYPE) && valgrind --leak-check=full --suppressions=$(BUILD_ROOT)/scripts/valgrind.sup ./mapbox-gl)
.PHONY: xlinux run-xlinux
xlinux: XCPRETTY := $(shell ./scripts/xcpretty.sh)
xlinux: Xcode/project
xcodebuild -project ./build/osx/gyp/osx.xcodeproj -configuration $(BUILDTYPE) -target linuxapp -jobs $(JOBS) $(XCPRETTY)
run-xlinux: xlinux
"gyp/build/$(BUILDTYPE)/mapbox-gl"
#### Android libaries #########################################################
.PRECIOUS: Makefile/android-%
Makefile/android-%: CMD = deps/run_gyp android/mapboxgl-app.gyp $(CONFIG_android-$*) $(LIBS_android) --generator-output=./build/android-$* -f make-android
Makefile/android-%: config/android-%.gypi styles/styles geojsonvt
@echo $(CMD)
@$(ENV_android-$*) $(CMD)
.PHONY: linux xlinux run-linux run-xlinux
linux: ; $(RUN) Makefile/linuxapp
.PHONY: android android-lib
# Builds a particular android architecture.
android-lib-%: Makefile/android-%
@$(ENV_android-$*) ./scripts/flock.py -v build/Android.lock $(MAKE) -C build/android-$* BUILDTYPE=$(BUILDTYPE) androidapp
android-lib-%: ; $(RUN) HOST=android HOST_VERSION=$* Makefile/androidapp
# Builds the default Android library
android-lib: ; $(RUN) HOST=android Makefile/androidapp
# Builds the selected/default Android library
android-lib: android-lib-$(ANDROID_ABI)
# Builds the selected/default Android library
android: android-lib-$(ANDROID_ABI)
android: android-lib
cd android/java && ./gradlew --parallel-threads=$(JOBS) assemble$(BUILDTYPE)
# Builds all android architectures.
android-all: $(ANDROID_ABIS)
android-all: android-lib-arm-v5 android-lib-arm-v7 android-lib-arm-v8
android-all: android-lib-x86 android-lib-x86-64
android-all: android-lib-mips android-lib-mips-64
cd android/java && ./gradlew --parallel-threads=$(JOBS) assemble$(BUILDTYPE)
# Full build of GL Core for each architecture, build the Android Library, publish to Maven Central
android-deploy: $(ANDROID_ABIS)
cd android/java/MapboxGLAndroidSDK && chmod ugo+x deploy.sh && ./deploy.sh
.PHONY: test
test: ; $(RUN) Makefile/test
test-%: ; $(RUN) test-$*
ifeq ($(BUILD),osx)
xtest: ; $(RUN) HOST=osx HOST_VERSION=x86_64 Xcode/test
endif
android-project: android-lib
##### Render builds ############################################################
render: Makefile/project
$(MAKE) -C build/$(HOST) BUILDTYPE=$(BUILDTYPE) mbgl-render
.PHONY: xrender
xrender: XCPRETTY := $(shell ./scripts/xcpretty.sh)
xrender: Xcode/project
xcodebuild -project ./build/osx/gyp/osx.xcodeproj -configuration $(BUILDTYPE) -target mbgl-render -jobs $(JOBS) $(XCPRETTY)
.PHONY: render xrender
render: ; $(RUN) Makefile/mbgl-render
ifeq ($(BUILD),osx)
xrender: ; $(RUN) HOST=osx HOST_VERSION=x86_64 Xcode/mbgl-render
endif
##### Maintenace operations ####################################################
.PHONY: clear_xcode_cache
clear_xcode_cache:
ifeq ($(PLATFORM), osx)
ifeq ($(BUILD), osx)
@CUSTOM_DD=`defaults read com.apple.dt.Xcode IDECustomDerivedDataLocation 2>/dev/null`; \
if [ $$CUSTOM_DD ]; then \
echo clearing files in $$CUSTOM_DD older than one day; \
@@ -233,7 +109,7 @@ endif
.PHONY: clear_sqlite_cache
clear_sqlite_cache:
ifeq ($(PLATFORM), osx)
ifeq ($(BUILD), osx)
rm -f ~/Library/Application\ Support/Mapbox\ GL/cache.db
else
rm -f /tmp/mbgl-cache.db

View File

@@ -42,6 +42,12 @@ jmethodID latLngConstructorId = nullptr;
jfieldID latLngLatitudeId = nullptr;
jfieldID latLngLongitudeId = nullptr;
jclass latLngZoomClass = nullptr;
jmethodID latLngZoomConstructorId = nullptr;
jfieldID latLngZoomLatitudeId = nullptr;
jfieldID latLngZoomLongitudeId = nullptr;
jfieldID latLngZoomZoomId = nullptr;
jclass markerClass = nullptr;
jmethodID markerConstructorId = nullptr;
jfieldID markerPositionId = nullptr;
@@ -65,13 +71,6 @@ jfieldID polygonStrokeWidthId = nullptr;
jfieldID polygonPointsId = nullptr;
jfieldID polygonHolesId = nullptr;
jclass latLngZoomClass = nullptr;
jmethodID latLngZoomConstructorId = nullptr;
jfieldID latLngZoomLatitudeId = nullptr;
jfieldID latLngZoomLongitudeId = nullptr;
jfieldID latLngZoomZoomId = nullptr;
jclass runtimeExceptionClass = nullptr;
jclass nullPointerExceptionClass = nullptr;
@@ -156,21 +155,21 @@ std::vector<std::string> std_vector_string_from_jobject(JNIEnv *env, jobject jli
return vector;
}
jobjectArray array =
jobjectArray jarray =
reinterpret_cast<jobjectArray>(env->CallObjectMethod(jlist, listToArrayId));
if (env->ExceptionCheck() || (array == nullptr)) {
if (env->ExceptionCheck() || (jarray == nullptr)) {
env->ExceptionDescribe();
return vector;
}
jsize len = env->GetArrayLength(array);
jsize len = env->GetArrayLength(jarray);
if (len < 0) {
env->ExceptionDescribe();
return vector;
}
for (jsize i = 0; i < len; i++) {
jstring jstr = reinterpret_cast<jstring>(env->GetObjectArrayElement(array, i));
jstring jstr = reinterpret_cast<jstring>(env->GetObjectArrayElement(jarray, i));
if (jstr == nullptr) {
env->ExceptionDescribe();
return vector;
@@ -179,61 +178,12 @@ std::vector<std::string> std_vector_string_from_jobject(JNIEnv *env, jobject jli
vector.push_back(std_string_from_jstring(env, jstr));
}
env->DeleteLocalRef(jarray);
jarray = nullptr;
return vector;
}
mbgl::AnnotationSegment annotation_segment_from_latlng_jlist(JNIEnv *env, jobject jlist) {
mbgl::AnnotationSegment segment;
if (jlist == nullptr) {
if (env->ThrowNew(nullPointerExceptionClass, "List cannot be null.") < 0) {
env->ExceptionDescribe();
return segment;
}
return segment;
}
jobjectArray array =
reinterpret_cast<jobjectArray>(env->CallObjectMethod(jlist, listToArrayId));
if (env->ExceptionCheck() || (array == nullptr)) {
env->ExceptionDescribe();
return segment;
}
jsize len = env->GetArrayLength(array);
if (len < 0) {
env->ExceptionDescribe();
return segment;
}
segment.reserve(len);
for (jsize i = 0; i < len; i++) {
jobject latLng = reinterpret_cast<jobject>(env->GetObjectArrayElement(array, i));
if (latLng == nullptr) {
env->ExceptionDescribe();
return segment;
}
jdouble latitude = env->GetDoubleField(latLng, latLngLatitudeId);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
return segment;
}
jdouble longitude = env->GetDoubleField(latLng, latLngLongitudeId);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
return segment;
}
segment.push_back(mbgl::LatLng(latitude, longitude));
env->DeleteLocalRef(latLng);
}
env->DeleteLocalRef(array);
return segment;
}
jobject std_vector_string_to_jobject(JNIEnv *env, std::vector<std::string> vector) {
jobject jlist = env->NewObject(arrayListClass, arrayListConstructorId);
if (jlist == nullptr) {
@@ -273,6 +223,91 @@ jlongArray std_vector_uint_to_jobject(JNIEnv *env, std::vector<uint32_t> vector)
return jarray;
}
mbgl::AnnotationSegment annotation_segment_from_latlng_jlist(JNIEnv *env, jobject jlist) {
mbgl::AnnotationSegment segment;
if (jlist == nullptr) {
if (env->ThrowNew(nullPointerExceptionClass, "List cannot be null.") < 0) {
env->ExceptionDescribe();
return segment;
}
return segment;
}
jobjectArray jarray =
reinterpret_cast<jobjectArray>(env->CallObjectMethod(jlist, listToArrayId));
if (env->ExceptionCheck() || (jarray == nullptr)) {
env->ExceptionDescribe();
return segment;
}
jsize len = env->GetArrayLength(jarray);
if (len < 0) {
env->ExceptionDescribe();
return segment;
}
segment.reserve(len);
for (jsize i = 0; i < len; i++) {
jobject latLng = reinterpret_cast<jobject>(env->GetObjectArrayElement(jarray, i));
if (latLng == nullptr) {
env->ExceptionDescribe();
return segment;
}
jdouble latitude = env->GetDoubleField(latLng, latLngLatitudeId);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
return segment;
}
jdouble longitude = env->GetDoubleField(latLng, latLngLongitudeId);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
return segment;
}
segment.push_back(mbgl::LatLng(latitude, longitude));
env->DeleteLocalRef(latLng);
}
env->DeleteLocalRef(jarray);
jarray = nullptr;
return segment;
}
std::pair<mbgl::AnnotationSegment, mbgl::StyleProperties> annotation_std_pair_from_polygon_jobject(JNIEnv *env, jobject polygon) {
jfloat alpha = env->GetFloatField(polygon, polygonAlphaId);
//jboolean visible = env->GetBooleanField(polygon, polygonVisibleId);
jint fillColor = env->GetIntField(polygon, polygonFillColorId);
jint strokeColor = env->GetIntField(polygon, polygonStrokeColorId);
int rF = (fillColor >> 16) & 0xFF;
int gF = (fillColor >> 8) & 0xFF;
int bF = (fillColor) & 0xFF;
int aF = (fillColor >> 24) & 0xFF;
int rS = (strokeColor >> 16) & 0xFF;
int gS = (strokeColor >> 8) & 0xFF;
int bS = (strokeColor) & 0xFF;
int aS = (strokeColor >> 24) & 0xFF;
mbgl::StyleProperties shapeProperties;
mbgl::FillProperties fillProperties;
fillProperties.opacity = alpha;
fillProperties.stroke_color = {{ static_cast<float>(rS) / 255.0f, static_cast<float>(gS) / 255.0f, static_cast<float>(bS) / 255.0f, static_cast<float>(aS) / 255.0f }};
fillProperties.fill_color = {{ static_cast<float>(rF) / 255.0f, static_cast<float>(gF) / 255.0f, static_cast<float>(bF) / 255.0f, static_cast<float>(aF) / 255.0f }};
shapeProperties.set<mbgl::FillProperties>(fillProperties);
jobject points = env->GetObjectField(polygon, polygonPointsId);
mbgl::AnnotationSegment segment = annotation_segment_from_latlng_jlist(env, points);
env->DeleteLocalRef(points);
return std::make_pair(segment, shapeProperties);
}
}
}
@@ -530,271 +565,6 @@ void JNICALL nativeSetLatLng(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, j
nativeMapView->getMap().setLatLng(mbgl::LatLng(latitude, longitude), std::chrono::milliseconds(duration));
}
void JNICALL nativeSetSprite(JNIEnv *env, jobject obj, jlong nativeMapViewPtr,
jstring symbol, jint width, jint height, jfloat scale, jbyteArray jpixels) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeSetSprite");
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
const std::string symbolName = std_string_from_jstring(env, symbol);
jbyte* pixelData = env->GetByteArrayElements(jpixels, nullptr);
std::string pixels((char*)pixelData, width * height * 4);
env->ReleaseByteArrayElements(jpixels, pixelData, JNI_ABORT);
auto spriteImage = std::make_shared<mbgl::SpriteImage>(
uint16_t(width),
uint16_t(height),
float(scale),
std::move(pixels));
nativeMapView->getMap().setSprite(symbolName, spriteImage);
}
jlong JNICALL nativeAddMarker(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jobject marker) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeAddMarker");
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
jobject position = env->GetObjectField(marker, markerPositionId);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
return -1;
}
jstring jsprite = (jstring)env->GetObjectField(marker, markerSpriteId);
std::string sprite = std_string_from_jstring(env, jsprite);
jdouble latitude = env->GetDoubleField(position, latLngLatitudeId);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
return -1;
}
jdouble longitude = env->GetDoubleField(position, latLngLongitudeId);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
return -1;
}
// Because Java only has int, not unsigned int, we need to bump the annotation id up to a long.
return (jlong) nativeMapView->getMap().addPointAnnotation(mbgl::PointAnnotation(mbgl::LatLng(latitude, longitude), sprite));
}
jlong JNICALL nativeAddPolyline(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jobject polyline) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeAddPolyline");
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
// ***** Java fields ***** //
// float alpha;
// boolean visible;
// int color
// float width
// List<LatLng> points
jfloat alpha = env->GetFloatField(polyline, polylineAlphaId);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
return -1;
}
jboolean visible = env->GetBooleanField(polyline, polylineVisibleId);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
return -1;
}
visible = JNI_TRUE;
jint color = env->GetIntField(polyline, polylineColorId);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
return -1;
}
int r = (color>>16)&0xFF;
int g = (color>>8)&0xFF;
int b = (color)&0xFF;
int a = (color>>24)&0xFF;
jfloat width = env->GetFloatField(polyline, polylineWidthId);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
return -1;
}
mbgl::StyleProperties shapeProperties;
mbgl::LineProperties lineProperties;
lineProperties.opacity = alpha;
lineProperties.color = {{ (float)r / 255.0f, (float)g / 255.0f, (float)b / 255.0f, (float)a / 255.0f }};
lineProperties.width = width;
shapeProperties.set<mbgl::LineProperties>(lineProperties);
jobject points = env->GetObjectField(polyline, polylinePointsId);
mbgl::AnnotationSegment segment = annotation_segment_from_latlng_jlist(env, points);
std::vector<mbgl::ShapeAnnotation> shapes;
shapes.emplace_back(mbgl::AnnotationSegments {{ segment }}, shapeProperties);
std::vector<uint32_t> shapeAnnotationIDs = nativeMapView->getMap().addShapeAnnotations(shapes);
uint32_t id = shapeAnnotationIDs.at(0);
return (jlong) id;
}
std::pair<mbgl::AnnotationSegment, mbgl::StyleProperties> readPolygon(JNIEnv *env, jobject polygon) {
// ***** Java fields ***** //
// float alpha;
// boolean visible;
// int fillColor
// int strokeColor
// float strokeWidth
// List<LatLng> points
// List<List<LatLng>> holes
jfloat alpha = env->GetFloatField(polygon, polygonAlphaId);
jboolean visible = env->GetBooleanField(polygon, polygonVisibleId);
visible = JNI_TRUE;
jint fillColor = env->GetIntField(polygon, polygonFillColorId);
jint strokeColor = env->GetIntField(polygon, polygonStrokeColorId);
int rF = (fillColor>>16)&0xFF;
int gF = (fillColor>>8)&0xFF;
int bF = (fillColor)&0xFF;
int aF = (fillColor>>24)&0xFF;
int rS = (strokeColor>>16)&0xFF;
int gS = (strokeColor>>8)&0xFF;
int bS = (strokeColor)&0xFF;
int aS = (strokeColor>>24)&0xFF;
// jfloat strokeWidth = env->GetFloatField(polygon, polygonStrokeWidthId);
// if (env->ExceptionCheck()) {
// env->ExceptionDescribe();
// return -1;
// }
mbgl::StyleProperties shapeProperties;
mbgl::FillProperties fillProperties;
fillProperties.opacity = alpha;
fillProperties.stroke_color = {{ (float)rS / 255.0f, (float)gS / 255.0f, (float)bS / 255.0f, (float)aS / 255.0f }};
fillProperties.fill_color = {{ (float)rF / 255.0f, (float)gF / 255.0f, (float)bF / 255.0f, (float)aF / 255.0f }};
shapeProperties.set<mbgl::FillProperties>(fillProperties);
jobject points = env->GetObjectField(polygon, polygonPointsId);
mbgl::AnnotationSegment segment = annotation_segment_from_latlng_jlist(env, points);
env->DeleteLocalRef(points);
return std::make_pair(segment, shapeProperties);
}
jlong JNICALL nativeAddPolygon(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jobject polygon) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeAddPolygon");
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
std::vector<mbgl::ShapeAnnotation> shapes;
std::pair<mbgl::AnnotationSegment, mbgl::StyleProperties> segment = readPolygon(env, polygon);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
return -1;
}
shapes.emplace_back(mbgl::AnnotationSegments {{ segment.first }}, segment.second);
std::vector<uint32_t> shapeAnnotationIDs = nativeMapView->getMap().addShapeAnnotations(shapes);
uint32_t id = shapeAnnotationIDs.at(0);
return (jlong) id;
}
jlongArray JNICALL nativeAddPolygons(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jobject jlist) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeAddPolygons");
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
std::vector<mbgl::ShapeAnnotation> shapes;
if (jlist == nullptr) {
if (env->ThrowNew(nullPointerExceptionClass, "List cannot be null.") < 0) {
env->ExceptionDescribe();
return nullptr;
}
return nullptr;
}
jobjectArray array =
reinterpret_cast<jobjectArray>(env->CallObjectMethod(jlist, listToArrayId));
if (env->ExceptionCheck() || (array == nullptr)) {
env->ExceptionDescribe();
return nullptr;
}
jsize len = env->GetArrayLength(array);
if (len < 0) {
env->ExceptionDescribe();
return nullptr;
}
shapes.reserve(len);
for (jsize i = 0; i < len; i++) {
jobject polygon = reinterpret_cast<jobject>(env->GetObjectArrayElement(array, i));
std::pair<mbgl::AnnotationSegment, mbgl::StyleProperties> segment = readPolygon(env, polygon);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
return nullptr;
}
shapes.emplace_back(mbgl::AnnotationSegments {{ segment.first }}, segment.second);
env->DeleteLocalRef(polygon);
}
std::vector<uint32_t> shapeAnnotationIDs = nativeMapView->getMap().addShapeAnnotations(shapes);
return std_vector_uint_to_jobject(env, shapeAnnotationIDs);
}
void JNICALL nativeRemoveAnnotation(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jlong annotationId) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeRemoveAnnotation");
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
nativeMapView->getMap().removeAnnotation((uint32_t)annotationId);
}
void JNICALL nativeRemoveAnnotations(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jlongArray array) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeRemoveAnnotations");
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
std::vector<uint32_t> ids;
if (env->ExceptionCheck() || (array == nullptr)) {
env->ExceptionDescribe();
return;
}
jsize len = env->GetArrayLength(array);
if (len < 0) {
env->ExceptionDescribe();
return;
}
ids.reserve(len);
jlong* jids = env->GetLongArrayElements(array, nullptr);
for (jsize i = 0; i < len; i++) {
if(jids[i] == -1L)
continue;
ids.push_back((uint32_t) jids[i]);
}
env->ReleaseLongArrayElements(array, jids, JNI_ABORT);
nativeMapView->getMap().removeAnnotations(ids);
}
jobject JNICALL nativeGetLatLng(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeGetLatLng");
assert(nativeMapViewPtr != 0);
@@ -956,6 +726,219 @@ void JNICALL nativeResetNorth(JNIEnv *env, jobject obj, jlong nativeMapViewPtr)
nativeMapView->getMap().resetNorth();
}
jlong JNICALL nativeAddMarker(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jobject marker) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeAddMarker");
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
jobject position = env->GetObjectField(marker, markerPositionId);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
return -1;
}
jstring jsprite = reinterpret_cast<jstring>(env->GetObjectField(marker, markerSpriteId));
std::string sprite = std_string_from_jstring(env, jsprite);
jdouble latitude = env->GetDoubleField(position, latLngLatitudeId);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
return -1;
}
jdouble longitude = env->GetDoubleField(position, latLngLongitudeId);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
return -1;
}
// Because Java only has int, not unsigned int, we need to bump the annotation id up to a long.
return nativeMapView->getMap().addPointAnnotation(mbgl::PointAnnotation(mbgl::LatLng(latitude, longitude), sprite));
}
jlong JNICALL nativeAddPolyline(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jobject polyline) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeAddPolyline");
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
jfloat alpha = env->GetFloatField(polyline, polylineAlphaId);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
return -1;
}
/*jboolean visible = env->GetBooleanField(polyline, polylineVisibleId);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
return -1;
}*/
jint color = env->GetIntField(polyline, polylineColorId);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
return -1;
}
int r = (color >> 16) & 0xFF;
int g = (color >> 8) & 0xFF;
int b = (color) & 0xFF;
int a = (color >> 24) & 0xFF;
jfloat width = env->GetFloatField(polyline, polylineWidthId);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
return -1;
}
mbgl::StyleProperties shapeProperties;
mbgl::LineProperties lineProperties;
lineProperties.opacity = alpha;
lineProperties.color = {{ static_cast<float>(r) / 255.0f, static_cast<float>(g) / 255.0f, static_cast<float>(b) / 255.0f, static_cast<float>(a) / 255.0f }};
lineProperties.width = width;
shapeProperties.set<mbgl::LineProperties>(lineProperties);
jobject points = env->GetObjectField(polyline, polylinePointsId);
mbgl::AnnotationSegment segment = annotation_segment_from_latlng_jlist(env, points);
std::vector<mbgl::ShapeAnnotation> shapes;
shapes.emplace_back(mbgl::AnnotationSegments { segment }, shapeProperties);
std::vector<uint32_t> shapeAnnotationIDs = nativeMapView->getMap().addShapeAnnotations(shapes);
uint32_t id = shapeAnnotationIDs.at(0);
return id;
}
jlong JNICALL nativeAddPolygon(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jobject polygon) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeAddPolygon");
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
std::vector<mbgl::ShapeAnnotation> shapes;
std::pair<mbgl::AnnotationSegment, mbgl::StyleProperties> segment = annotation_std_pair_from_polygon_jobject(env, polygon);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
return -1;
}
shapes.emplace_back(mbgl::AnnotationSegments { segment.first }, segment.second);
std::vector<uint32_t> shapeAnnotationIDs = nativeMapView->getMap().addShapeAnnotations(shapes);
uint32_t id = shapeAnnotationIDs.at(0);
return id;
}
jlongArray JNICALL nativeAddPolygons(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jobject jlist) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeAddPolygons");
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
std::vector<mbgl::ShapeAnnotation> shapes;
if (jlist == nullptr) {
if (env->ThrowNew(nullPointerExceptionClass, "List cannot be null.") < 0) {
env->ExceptionDescribe();
return nullptr;
}
return nullptr;
}
jobjectArray jarray =
reinterpret_cast<jobjectArray>(env->CallObjectMethod(jlist, listToArrayId));
if (env->ExceptionCheck() || (jarray == nullptr)) {
env->ExceptionDescribe();
return nullptr;
}
jsize len = env->GetArrayLength(jarray);
if (len < 0) {
env->ExceptionDescribe();
return nullptr;
}
shapes.reserve(len);
for (jsize i = 0; i < len; i++) {
jobject polygon = reinterpret_cast<jobject>(env->GetObjectArrayElement(jarray, i));
std::pair<mbgl::AnnotationSegment, mbgl::StyleProperties> segment = annotation_std_pair_from_polygon_jobject(env, polygon);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
return nullptr;
}
shapes.emplace_back(mbgl::AnnotationSegments { segment.first }, segment.second);
env->DeleteLocalRef(polygon);
}
env->DeleteLocalRef(jarray);
std::vector<uint32_t> shapeAnnotationIDs = nativeMapView->getMap().addShapeAnnotations(shapes);
return std_vector_uint_to_jobject(env, shapeAnnotationIDs);
}
void JNICALL nativeRemoveAnnotation(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jlong annotationId) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeRemoveAnnotation");
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
nativeMapView->getMap().removeAnnotation(static_cast<uint32_t>(annotationId));
}
void JNICALL nativeRemoveAnnotations(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jlongArray jarray) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeRemoveAnnotations");
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
std::vector<uint32_t> ids;
if (env->ExceptionCheck() || (jarray == nullptr)) {
env->ExceptionDescribe();
return;
}
jsize len = env->GetArrayLength(jarray);
if (len < 0) {
env->ExceptionDescribe();
return;
}
ids.reserve(len);
jlong* jids = env->GetLongArrayElements(jarray, nullptr);
for (jsize i = 0; i < len; i++) {
if(jids[i] == -1L)
continue;
ids.push_back(static_cast<uint32_t>(jids[i]));
}
env->ReleaseLongArrayElements(jarray, jids, JNI_ABORT);
nativeMapView->getMap().removeAnnotations(ids);
}
void JNICALL nativeSetSprite(JNIEnv *env, jobject obj, jlong nativeMapViewPtr,
jstring symbol, jint width, jint height, jfloat scale, jbyteArray jpixels) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeSetSprite");
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
const std::string symbolName = std_string_from_jstring(env, symbol);
jbyte* pixelData = env->GetByteArrayElements(jpixels, nullptr);
std::string pixels(reinterpret_cast<char*>(pixelData), width * height * 4);
env->ReleaseByteArrayElements(jpixels, pixelData, JNI_ABORT);
auto spriteImage = std::make_shared<mbgl::SpriteImage>(
uint16_t(width),
uint16_t(height),
float(scale),
std::move(pixels));
nativeMapView->getMap().setSprite(symbolName, spriteImage);
}
void JNICALL nativeOnLowMemory(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeOnLowMemory");
assert(nativeMapViewPtr != 0);
@@ -1179,6 +1162,36 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
return JNI_ERR;
}
latLngZoomClass = env->FindClass("com/mapbox/mapboxgl/geometry/LatLngZoom");
if (latLngZoomClass == nullptr) {
env->ExceptionDescribe();
return JNI_ERR;
}
latLngZoomConstructorId = env->GetMethodID(latLngZoomClass, "<init>", "(DDD)V");
if (latLngZoomConstructorId == nullptr) {
env->ExceptionDescribe();
return JNI_ERR;
}
latLngZoomLatitudeId = env->GetFieldID(latLngZoomClass, "latitude", "D");
if (latLngZoomLatitudeId == nullptr) {
env->ExceptionDescribe();
return JNI_ERR;
}
latLngZoomLongitudeId = env->GetFieldID(latLngZoomClass, "longitude", "D");
if (latLngZoomLongitudeId == nullptr) {
env->ExceptionDescribe();
return JNI_ERR;
}
latLngZoomZoomId = env->GetFieldID(latLngZoomClass, "zoom", "D");
if (latLngZoomZoomId == nullptr) {
env->ExceptionDescribe();
return JNI_ERR;
}
markerClass = env->FindClass("com/mapbox/mapboxgl/annotations/Marker");
if (markerClass == nullptr) {
env->ExceptionDescribe();
@@ -1299,36 +1312,6 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
return JNI_ERR;
}
latLngZoomClass = env->FindClass("com/mapbox/mapboxgl/geometry/LatLngZoom");
if (latLngZoomClass == nullptr) {
env->ExceptionDescribe();
return JNI_ERR;
}
latLngZoomConstructorId = env->GetMethodID(latLngZoomClass, "<init>", "(DDD)V");
if (latLngZoomConstructorId == nullptr) {
env->ExceptionDescribe();
return JNI_ERR;
}
latLngZoomLatitudeId = env->GetFieldID(latLngZoomClass, "latitude", "D");
if (latLngZoomLatitudeId == nullptr) {
env->ExceptionDescribe();
return JNI_ERR;
}
latLngZoomLongitudeId = env->GetFieldID(latLngZoomClass, "longitude", "D");
if (latLngZoomLongitudeId == nullptr) {
env->ExceptionDescribe();
return JNI_ERR;
}
latLngZoomZoomId = env->GetFieldID(latLngZoomClass, "zoom", "D");
if (latLngZoomZoomId == nullptr) {
env->ExceptionDescribe();
return JNI_ERR;
}
jclass nativeMapViewClass = env->FindClass("com/mapbox/mapboxgl/views/NativeMapView");
if (nativeMapViewClass == nullptr) {
env->ExceptionDescribe();
@@ -1492,17 +1475,6 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
{"nativeMoveBy", "(JDDJ)V", reinterpret_cast<void *>(&nativeMoveBy)},
{"nativeSetLatLng", "(JLcom/mapbox/mapboxgl/geometry/LatLng;J)V",
reinterpret_cast<void *>(&nativeSetLatLng)},
{"nativeSetSprite", "(JLjava/lang/String;IIF[B)V", reinterpret_cast<void *>(&nativeSetSprite)},
{"nativeAddMarker", "(JLcom/mapbox/mapboxgl/annotations/Marker;)J",
reinterpret_cast<void *>(&nativeAddMarker)},
{"nativeAddPolyline", "(JLcom/mapbox/mapboxgl/annotations/Polyline;)J",
reinterpret_cast<void *>(&nativeAddPolyline)},
{"nativeAddPolygon", "(JLcom/mapbox/mapboxgl/annotations/Polygon;)J",
reinterpret_cast<void *>(&nativeAddPolygon)},
{"nativeAddPolygons", "(JLjava/util/List;)[J",
reinterpret_cast<void *>(&nativeAddPolygons)},
{"nativeRemoveAnnotation", "(JJ)V", reinterpret_cast<void *>(&nativeRemoveAnnotation)},
{"nativeRemoveAnnotations", "(J[J)V", reinterpret_cast<void *>(&nativeRemoveAnnotations)},
{"nativeGetLatLng", "(J)Lcom/mapbox/mapboxgl/geometry/LatLng;",
reinterpret_cast<void *>(&nativeGetLatLng)},
{"nativeResetPosition", "(J)V", reinterpret_cast<void *>(&nativeResetPosition)},
@@ -1529,6 +1501,17 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
&nativeSetBearing))},
{"nativeGetBearing", "(J)D", reinterpret_cast<void *>(&nativeGetBearing)},
{"nativeResetNorth", "(J)V", reinterpret_cast<void *>(&nativeResetNorth)},
{"nativeAddMarker", "(JLcom/mapbox/mapboxgl/annotations/Marker;)J",
reinterpret_cast<void *>(&nativeAddMarker)},
{"nativeAddPolyline", "(JLcom/mapbox/mapboxgl/annotations/Polyline;)J",
reinterpret_cast<void *>(&nativeAddPolyline)},
{"nativeAddPolygon", "(JLcom/mapbox/mapboxgl/annotations/Polygon;)J",
reinterpret_cast<void *>(&nativeAddPolygon)},
{"nativeAddPolygons", "(JLjava/util/List;)[J",
reinterpret_cast<void *>(&nativeAddPolygons)},
{"nativeRemoveAnnotation", "(JJ)V", reinterpret_cast<void *>(&nativeRemoveAnnotation)},
{"nativeRemoveAnnotations", "(J[J)V", reinterpret_cast<void *>(&nativeRemoveAnnotations)},
{"nativeSetSprite", "(JLjava/lang/String;IIF[B)V", reinterpret_cast<void *>(&nativeSetSprite)},
{"nativeOnLowMemory", "(J)V", reinterpret_cast<void *>(&nativeOnLowMemory)},
{"nativeSetDebug", "(JZ)V", reinterpret_cast<void *>(&nativeSetDebug)},
{"nativeToggleDebug", "(J)V", reinterpret_cast<void *>(&nativeToggleDebug)},
@@ -1558,28 +1541,37 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
return JNI_ERR;
}
latLngZoomClass = reinterpret_cast<jclass>(env->NewGlobalRef(latLngZoomClass));
if (latLngZoomClass == nullptr) {
env->ExceptionDescribe();
env->DeleteGlobalRef(latLngClass);
return JNI_ERR;
}
markerClass = reinterpret_cast<jclass>(env->NewGlobalRef(markerClass));
if (markerClass == nullptr) {
env->ExceptionDescribe();
env->DeleteGlobalRef(latLngClass);
env->DeleteGlobalRef(latLngZoomClass);
return JNI_ERR;
}
polylineClass = reinterpret_cast<jclass>(env->NewGlobalRef(polylineClass));
if (polylineClass == nullptr) {
env->ExceptionDescribe();
env->DeleteGlobalRef(latLngClass);
env->DeleteGlobalRef(latLngZoomClass);
env->DeleteGlobalRef(markerClass);
return JNI_ERR;
}
polygonClass = reinterpret_cast<jclass>(env->NewGlobalRef(polygonClass));
if (polygonClass == nullptr) {
env->ExceptionDescribe();
return JNI_ERR;
}
latLngZoomClass = reinterpret_cast<jclass>(env->NewGlobalRef(latLngZoomClass));
if (latLngZoomClass == nullptr) {
env->ExceptionDescribe();
env->DeleteGlobalRef(latLngClass);
env->DeleteGlobalRef(latLngZoomClass);
env->DeleteGlobalRef(markerClass);
env->DeleteGlobalRef(polylineClass);
return JNI_ERR;
}
@@ -1588,6 +1580,9 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
env->ExceptionDescribe();
env->DeleteGlobalRef(latLngClass);
env->DeleteGlobalRef(latLngZoomClass);
env->DeleteGlobalRef(markerClass);
env->DeleteGlobalRef(polylineClass);
env->DeleteGlobalRef(polygonClass);
return JNI_ERR;
}
@@ -1597,6 +1592,9 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
env->ExceptionDescribe();
env->DeleteGlobalRef(latLngClass);
env->DeleteGlobalRef(latLngZoomClass);
env->DeleteGlobalRef(markerClass);
env->DeleteGlobalRef(polylineClass);
env->DeleteGlobalRef(polygonClass);
env->DeleteGlobalRef(runtimeExceptionClass);
return JNI_ERR;
}
@@ -1606,6 +1604,9 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
env->ExceptionDescribe();
env->DeleteGlobalRef(latLngClass);
env->DeleteGlobalRef(latLngZoomClass);
env->DeleteGlobalRef(markerClass);
env->DeleteGlobalRef(polylineClass);
env->DeleteGlobalRef(polygonClass);
env->DeleteGlobalRef(runtimeExceptionClass);
env->DeleteGlobalRef(nullPointerExceptionClass);
return JNI_ERR;
@@ -1616,18 +1617,23 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
env->ExceptionDescribe();
env->DeleteGlobalRef(latLngClass);
env->DeleteGlobalRef(latLngZoomClass);
env->DeleteGlobalRef(markerClass);
env->DeleteGlobalRef(polylineClass);
env->DeleteGlobalRef(polygonClass);
env->DeleteGlobalRef(runtimeExceptionClass);
env->DeleteGlobalRef(nullPointerExceptionClass);
env->DeleteGlobalRef(arrayListClass);
return JNI_ERR;
}
pointFClass = reinterpret_cast<jclass>(env->NewGlobalRef(pointFClass));
if (pointFClass == nullptr) {
env->ExceptionDescribe();
env->DeleteGlobalRef(latLngClass);
env->DeleteGlobalRef(markerClass);
env->DeleteGlobalRef(latLngZoomClass);
env->DeleteGlobalRef(polylineClass);
env->DeleteGlobalRef(polygonClass);
env->DeleteGlobalRef(runtimeExceptionClass);
env->DeleteGlobalRef(nullPointerExceptionClass);
env->DeleteGlobalRef(arrayListClass);
@@ -1635,7 +1641,6 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
return JNI_ERR;
}
char release[PROP_VALUE_MAX] = "";
__system_property_get("ro.build.version.release", release);
androidRelease = std::string(release);
@@ -1659,6 +1664,13 @@ extern "C" JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved) {
latLngLongitudeId = nullptr;
latLngLatitudeId = nullptr;
env->DeleteGlobalRef(latLngZoomClass);
latLngZoomClass = nullptr;
latLngZoomConstructorId = nullptr;
latLngZoomLongitudeId = nullptr;
latLngZoomLatitudeId = nullptr;
latLngZoomZoomId = nullptr;
env->DeleteGlobalRef(markerClass);
markerClass = nullptr;
markerConstructorId = nullptr;
@@ -1685,14 +1697,6 @@ extern "C" JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved) {
polygonPointsId = nullptr;
polygonHolesId = nullptr;
env->DeleteGlobalRef(latLngZoomClass);
latLngZoomClass = nullptr;
latLngZoomConstructorId = nullptr;
latLngZoomLongitudeId = nullptr;
latLngZoomLatitudeId = nullptr;
latLngZoomZoomId = nullptr;
onInvalidateId = nullptr;
onMapChangedId = nullptr;
onFpsChangedId = nullptr;

View File

@@ -10,20 +10,19 @@ public abstract class Annotation {
*
* Internal C++ id is stored as unsigned int.
*/
protected Long id; // null unless added to a MapView
protected long id = -1; // -1 unless added to a MapView
private MapView mapView;
float alpha = 1;
float alpha = 1.0f;
boolean visible = true;
public Annotation() {}
public float getAlpha() {
return alpha;
}
public Long getId() {
public long getId() {
return id;
}
@@ -40,7 +39,7 @@ public abstract class Annotation {
this.alpha = alpha;
}
public void setId(Long id) {
public void setId(long id) {
this.id = id;
}

View File

@@ -314,7 +314,7 @@ public class MapView extends FrameLayout implements LocationListener {
public Marker addMarker(MarkerOptions markerOptions) {
Marker marker = markerOptions.getMarker();
Long id = mNativeMapView.addMarker(marker);
long id = mNativeMapView.addMarker(marker);
marker.setId(id); // the annotation needs to know its id
marker.setMapView(this); // the annotation needs to know which map view it is in
annotations.add(marker);
@@ -323,7 +323,7 @@ public class MapView extends FrameLayout implements LocationListener {
public Polyline addPolyline(PolylineOptions polylineOptions) {
Polyline polyline = polylineOptions.getPolyline();
Long id = mNativeMapView.addPolyline(polyline);
long id = mNativeMapView.addPolyline(polyline);
polyline.setId(id);
polyline.setMapView(this);
annotations.add(polyline);
@@ -332,7 +332,7 @@ public class MapView extends FrameLayout implements LocationListener {
public Polygon addPolygon(PolygonOptions polygonOptions) {
Polygon polygon = polygonOptions.getPolygon();
Long id = mNativeMapView.addPolygon(polygon);
long id = mNativeMapView.addPolygon(polygon);
polygon.setId(id);
polygon.setMapView(this);
annotations.add(polygon);
@@ -347,7 +347,7 @@ public class MapView extends FrameLayout implements LocationListener {
long[] ids = mNativeMapView.addPolygons(polygons);
for(int i=0; i<polygons.size(); i++) {
for(int i=0; i < polygons.size(); i++) {
polygons.get(i).setId(ids[i]);
polygons.get(i).setMapView(this);
annotations.add(polygons.get(i));
@@ -367,13 +367,9 @@ public class MapView extends FrameLayout implements LocationListener {
public void removeAnnotations() {
long[] ids = new long[annotations.size()];
for(int i=0; i<annotations.size(); i++) {
Long id = annotations.get(i).getId();
if(id == null) {
ids[i] = -1;
} else {
ids[i] = id;
}
for(int i = 0; i < annotations.size(); i++) {
long id = annotations.get(i).getId();
ids[i] = id;
}
mNativeMapView.removeAnnotations(ids);
}

View File

@@ -224,37 +224,6 @@ class NativeMapView {
nativeSetLatLng(mNativeMapViewPtr, latLng, duration);
}
public void setSprite(String symbol, int width, int height, float scale, byte[] pixels) {
nativeSetSprite(mNativeMapViewPtr, symbol, width, height, scale, pixels);
}
public long addMarker(Marker marker) {
return nativeAddMarker(mNativeMapViewPtr, marker);
}
public long addPolyline(Polyline polyline) {
// NH TODO Throw exception if returns -1
return nativeAddPolyline(mNativeMapViewPtr, polyline);
}
public long addPolygon(Polygon polygon) {
// NH TODO Throw exception if returns -1
return nativeAddPolygon(mNativeMapViewPtr, polygon);
}
public long[] addPolygons(List<Polygon> polygon) {
// NH TODO Throw exception if returns -1
return nativeAddPolygons(mNativeMapViewPtr, polygon);
}
public void removeAnnotation(long id) {
nativeRemoveAnnotation(mNativeMapViewPtr, id);
}
public void removeAnnotations(long[] ids) {
nativeRemoveAnnotations(mNativeMapViewPtr, ids);
}
public LatLng getLatLng() {
return nativeGetLatLng(mNativeMapViewPtr);
}
@@ -356,6 +325,34 @@ class NativeMapView {
nativeResetNorth(mNativeMapViewPtr);
}
public long addMarker(Marker marker) {
return nativeAddMarker(mNativeMapViewPtr, marker);
}
public long addPolyline(Polyline polyline) {
return nativeAddPolyline(mNativeMapViewPtr, polyline);
}
public long addPolygon(Polygon polygon) {
return nativeAddPolygon(mNativeMapViewPtr, polygon);
}
public long[] addPolygons(List<Polygon> polygon) {
return nativeAddPolygons(mNativeMapViewPtr, polygon);
}
public void removeAnnotation(long id) {
nativeRemoveAnnotation(mNativeMapViewPtr, id);
}
public void removeAnnotations(long[] ids) {
nativeRemoveAnnotations(mNativeMapViewPtr, ids);
}
public void setSprite(String symbol, int width, int height, float scale, byte[] pixels) {
nativeSetSprite(mNativeMapViewPtr, symbol, width, height, scale, pixels);
}
public void onLowMemory() {
nativeOnLowMemory(mNativeMapViewPtr);
}
@@ -392,7 +389,7 @@ class NativeMapView {
nativeSetReachability(mNativeMapViewPtr, status);
}
//public void getWorldBoundsMeters();
//public void ();
//public void getWorldBoundsLatLng();
@@ -507,21 +504,6 @@ class NativeMapView {
private native void nativeSetLatLng(long nativeMapViewPtr, LatLng latLng,
long duration);
private native void nativeSetSprite(long nativeMapViewPtr, String symbol,
int width, int height, float scale, byte[] pixels);
private native long nativeAddMarker(long nativeMapViewPtr, Marker marker);
private native long nativeAddPolyline(long nativeMapViewPtr, Polyline polyline);
private native long nativeAddPolygon(long mNativeMapViewPtr, Polygon polygon);
private native long[] nativeAddPolygons(long mNativeMapViewPtr, List<Polygon> polygon);
private native void nativeRemoveAnnotation(long nativeMapViewPtr, long id);
private native void nativeRemoveAnnotations(long nativeMapViewPtr, long[] id);
private native LatLng nativeGetLatLng(long nativeMapViewPtr);
private native void nativeResetPosition(long nativeMapViewPtr);
@@ -563,6 +545,21 @@ class NativeMapView {
private native void nativeResetNorth(long nativeMapViewPtr);
private native long nativeAddMarker(long nativeMapViewPtr, Marker marker);
private native long nativeAddPolyline(long nativeMapViewPtr, Polyline polyline);
private native long nativeAddPolygon(long mNativeMapViewPtr, Polygon polygon);
private native long[] nativeAddPolygons(long mNativeMapViewPtr, List<Polygon> polygon);
private native void nativeRemoveAnnotation(long nativeMapViewPtr, long id);
private native void nativeRemoveAnnotations(long nativeMapViewPtr, long[] id);
private native void nativeSetSprite(long nativeMapViewPtr, String symbol,
int width, int height, float scale, byte[] pixels);
private native void nativeOnLowMemory(long nativeMapViewPtr);
private native void nativeSetDebug(long nativeMapViewPtr, boolean debug);

View File

@@ -1,4 +1,4 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
task wrapper(type: Wrapper) {
gradleVersion = '2.2.1'
gradleVersion = '2.5'
}

Binary file not shown.

View File

@@ -1,6 +1,6 @@
#Sat Dec 06 12:43:10 EST 2014
#Mon Aug 03 17:09:27 CDT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-bin.zip

View File

@@ -26,13 +26,13 @@
],
'libraries': [
'<@(openssl_static_libs)',
'<@(curl_static_libs)',
'<@(png_static_libs)',
'<@(libcurl_static_libs)',
'<@(libpng_static_libs)',
'<@(jpeg_static_libs)',
'<@(sqlite3_static_libs)',
'<@(uv_static_libs)',
'<@(nu_static_libs)',
'<@(zip_static_libs)',
'<@(sqlite_static_libs)',
'<@(libuv_static_libs)',
'<@(nunicode_static_libs)',
'<@(libzip_static_libs)',
],
'variables': {
'ldflags': [
@@ -42,13 +42,13 @@
'-lGLESv2',
'-lstdc++',
'-latomic',
'<@(png_ldflags)',
'<@(libpng_ldflags)',
'<@(jpeg_ldflags)',
'<@(sqlite3_ldflags)',
'<@(sqlite_ldflags)',
'<@(openssl_ldflags)',
'<@(curl_ldflags)',
'<@(libcurl_ldflags)',
'<@(zlib_ldflags)',
'<@(zip_ldflags)',
'<@(libzip_ldflags)',
],
},
'conditions': [
@@ -77,7 +77,7 @@
'../common/ca-bundle.crt',
'../styles/styles'
],
'destination': '<(pwd)/java/MapboxGLAndroidSDK/src/main/assets'
'destination': '<(pwd)/../android/java/MapboxGLAndroidSDK/src/main/assets'
},
],
@@ -85,7 +85,7 @@
{
'action_name': 'Strip dynamic library',
'inputs': [ '<(PRODUCT_DIR)/lib.target/libmapbox-gl.so' ],
'outputs': [ '<(pwd)/java/MapboxGLAndroidSDK/src/main/jniLibs/$(JNIDIR)/libmapbox-gl.so' ],
'outputs': [ '<(pwd)/../android/java/MapboxGLAndroidSDK/src/main/jniLibs/$(JNIDIR)/libmapbox-gl.so' ],
'action': [ '$(STRIP)', '<@(_inputs)', '-o', '<@(_outputs)' ]
},
],

View File

@@ -27,18 +27,18 @@
'variables' : {
'cflags_cc': [
'<@(glfw3_cflags)',
'<@(uv_cflags)',
'<@(glfw_cflags)',
'<@(libuv_cflags)',
'<@(boost_cflags)',
],
'ldflags': [
'<@(glfw3_ldflags)',
'<@(uv_ldflags)',
'<@(glfw_ldflags)',
'<@(libuv_ldflags)',
],
'libraries': [
'<@(glfw3_static_libs)',
'<@(uv_static_libs)',
'<@(boost_program_options_static_libs)'
'<@(glfw_static_libs)',
'<@(libuv_static_libs)',
'<@(boost_libprogram_options_static_libs)'
],
},

View File

@@ -1,67 +0,0 @@
#### Configuration defaults ####################################################
ENV_osx = MASON_PLATFORM=osx
CONFIG_osx = -Dhost=osx -Iconfig/osx.gypi -Dinstall_prefix=$(PREFIX)
LIBS_osx = -Dheadless_lib=$(word 1,$(HEADLESS) cgl)
LIBS_osx += -Dplatform_lib=$(word 1,$(PLATFORM) osx)
LIBS_osx += -Dasset_lib=$(word 1,$(ASSET) fs)
LIBS_osx += -Dhttp_lib=$(word 1,$(HTTP) nsurl)
LIBS_osx += -Dcache_lib=$(word 1,$(CACHE) sqlite)
LIBS_osx += --depth=. -Goutput_dir=.
ENV_ios = MASON_PLATFORM=ios
CONFIG_ios = -Dhost=ios -Iconfig/ios.gypi -Dinstall_prefix=$(PREFIX)
LIBS_ios = -Dheadless_lib=none
LIBS_ios += -Dplatform_lib=$(word 1,$(PLATFORM) ios)
LIBS_ios += -Dasset_lib=$(word 1,$(ASSET) fs)
LIBS_ios += -Dhttp_lib=$(word 1,$(HTTP) nsurl)
LIBS_ios += -Dcache_lib=$(word 1,$(CACHE) sqlite)
LIBS_ios += --depth=. -Goutput_dir=.
ENV_linux = MASON_PLATFORM=linux
CONFIG_linux = -Dhost=linux -Iconfig/linux.gypi -Dinstall_prefix=$(PREFIX)
LIBS_linux = -Dheadless_lib=$(word 1,$(HEADLESS) glx)
LIBS_linux += -Dplatform_lib=$(word 1,$(PLATFORM) linux)
LIBS_linux += -Dasset_lib=$(word 1,$(ASSET) fs)
LIBS_linux += -Dhttp_lib=$(word 1,$(HTTP) curl)
LIBS_linux += -Dcache_lib=$(word 1,$(CACHE) sqlite)
LIBS_linux += --depth=. -Goutput_dir=.
ANDROID_ABIS += android-lib-arm-v8
ENV_android-arm-v8 = $(shell MASON_ANDROID_ABI=arm-v8 ./scripts/android/toolchain.sh)
CONFIG_android-arm-v8 = -Dhost=android -Iconfig/android-arm-v8.gypi
ANDROID_ABIS += android-lib-arm-v7
ENV_android-arm-v7 = $(shell MASON_ANDROID_ABI=arm-v7 ./scripts/android/toolchain.sh)
CONFIG_android-arm-v7 = -Dhost=android -Iconfig/android-arm-v7.gypi
ANDROID_ABIS += android-lib-arm-v5
ENV_android-arm-v5 = $(shell MASON_ANDROID_ABI=arm-v5 ./scripts/android/toolchain.sh)
CONFIG_android-arm-v5 = -Dhost=android -Iconfig/android-arm-v5.gypi
ANDROID_ABIS += android-lib-x86
ENV_android-x86 = $(shell MASON_ANDROID_ABI=x86 ./scripts/android/toolchain.sh)
CONFIG_android-x86 = -Dhost=android -Iconfig/android-x86.gypi
# OpenSSL build is incomplete.
# ANDROID_ABIS += android-lib-x86-64
# ENV_android-x86-64 = $(shell MASON_ANDROID_ABI=x86-64 ./scripts/android/toolchain.sh)
# CONFIG_android-x86-64 = -Dhost=android -Iconfig/android-x86-64.gypi
ANDROID_ABIS += android-lib-mips
ENV_android-mips = $(shell MASON_ANDROID_ABI=mips ./scripts/android/toolchain.sh)
CONFIG_android-mips = -Dhost=android -Iconfig/android-mips.gypi
ANDROID_ABIS += android-lib-mips-64
ENV_android-mips-64 = $(shell MASON_ANDROID_ABI=mips-64 ./scripts/android/toolchain.sh)
CONFIG_android-mips-64 = -Dhost=android -Iconfig/android-mips-64.gypi
LIBS_android = -Dheadless_lib=none
LIBS_android += -Dplatform_lib=$(word 1,$(PLATFORM) android)
LIBS_android += -Dasset_lib=$(word 1,$(ASSET) zip)
LIBS_android += -Dhttp_lib=$(word 1,$(HTTP) curl)
LIBS_android += -Dcache_lib=$(word 1,$(CACHE) sqlite)
LIBS_android += --depth=. -Goutput_dir=.

217
configure vendored
View File

@@ -1,76 +1,56 @@
#!/usr/bin/env bash
set -e
set -o pipefail
set -euo pipefail
CONFIG_FILE=$1
if [ `uname -s` = 'Darwin' ]; then
MASON_PLATFORM=${MASON_PLATFORM:-osx}
fi
function finish {
>&2 echo -en "\033[0m";
}
trap finish EXIT
# Install mason
git submodule update --init .mason
export PATH="`pwd`/.mason:${PATH}" MASON_DIR="`pwd`/.mason"
case ${MASON_PLATFORM} in
'ios')
SQLITE_VERSION=system
LIBUV_VERSION=0.10.28
ZLIB_VERSION=system
BOOST_VERSION=system
;;
'android')
SQLITE_VERSION=3.8.8.1
LIBPNG_VERSION=1.6.16
LIBJPEG_VERSION=v9a
OPENSSL_VERSION=1.0.1l
LIBCURL_VERSION=7.40.0
LIBUV_VERSION=1.4.0
ZLIB_VERSION=system
BOOST_VERSION=1.57.0
NUNICODE_VERSION=1.5.1
LIBZIP_VERSION=0.11.2
;;
*)
GLFW_VERSION=3.1
SQLITE_VERSION=3.8.8.1
LIBPNG_VERSION=1.6.16
LIBJPEG_VERSION=v9a
LIBCURL_VERSION=system
LIBUV_VERSION=0.10.28
ZLIB_VERSION=system
BOOST_VERSION=1.57.0
BOOST_PROGRAM_OPTIONS_VERSION=1.57.0
NUNICODE_VERSION=1.5.1
LIBZIP_VERSION=0.11.2
;;
esac
if [ ${MASON_PLATFORM} == 'linux' ] ; then
MESA_VERSION=10.4.3
mason install mesa ${MESA_VERSION}
export PKG_CONFIG_PATH=`mason prefix mesa ${MESA_VERSION}`/lib/pkgconfig
fi
function abort { >&2 echo -e "\033[1m\033[31m$1\033[0m"; exit 1; }
if [ -z ${CONFIG_FILE} ]; then
abort 'You need to specify an output path for the configuration file'
fi
if [[ ${MASON_PLATFORM} = 'android' && -z ${MASON_ANDROID_ABI} ]]; then
abort 'You need to specify an ABI for android platforms'
fi
# Make sure we clear all colors
trap '>&2 echo -en "\033[0m"' TERM INT
echo -n "MASON_PLATFORM=${MASON_PLATFORM} "
if [ ${MASON_PLATFORM} = 'android' ]; then echo -n "MASON_ANDROID_ABI=${MASON_ANDROID_ABI} " ; fi
echo $0 $@
function abort { >&2 echo -e "\033[1m\033[31m$1\033[0m"; exit 1; }
function info { >&2 echo -e "\033[1m\033[33m$1\033[0m"; }
function warn { >&2 echo -e "\033[1m\033[33m$1\033[0m"; }
# Install mason
export PATH="`pwd`/.mason:${PATH}" MASON_DIR="`pwd`/.mason"
# You can override the function for a particular set of flags by defining a
# print_XXX_flags function in your dependencies.sh file
function print_flags {
local NAME=$1; shift
if [ "$(type -t print_${NAME}_flags)" = 'function' ]; then
print_${NAME}_flags
else
local VERSION=`echo "${NAME}_VERSION" | tr "[:lower:]" "[:upper:]"`
if [ ! -z ${!VERSION:-} ] ; then
mason install ${NAME} ${!VERSION}
for FLAGS in "$@" ; do
CONFIG+=" '${NAME}_${FLAGS}%': $(quote_flags $(mason ${FLAGS} ${NAME} ${!VERSION})),"$LN
done
else
warn "* Not using ${NAME}"
fi
fi
}
function print_default_flags {
:
}
function print_opengl_flags {
CONFIG+=" 'opengl_cflags%': [],"$LN
CONFIG+=" 'opengl_ldflags%': [],"$LN
}
# Load dependencies
source scripts/${MASON_PLATFORM}/configure.sh
if [ -e scripts/${MASON_PLATFORM}/${MASON_PLATFORM_VERSION}/configure.sh ]; then
source scripts/${MASON_PLATFORM}/${MASON_PLATFORM_VERSION}/configure.sh
fi
PYTHON=`which python || abort 'Cannot find python'`
@@ -78,12 +58,6 @@ PYTHON=`which python || abort 'Cannot find python'`
>&2 ${PYTHON} --version
>&2 echo -en "\033[0m";
PKG_CONFIG=`which pkg-config || abort 'Cannot find pkg-config'`
>&2 echo -en "\033[1m\033[32m* Using pkg-config "
>&2 ${PKG_CONFIG} --version
>&2 echo -en "\033[0m";
function quote_flags {
${PYTHON} -c "import sys, re; print filter(None, re.split('(?<!-framework)\s+', ' '.join(sys.argv[1:])))" "$@"
}
@@ -97,102 +71,33 @@ CONFIG="# Do not edit. Generated by the configure script.
'default_configuration': 'Release',
'defines': [],
'include_dirs': [],
'libraries': []
},
'variables': {
'libraries': [],
"
if [ ! -z ${BOOST_VERSION} ]; then
mason install boost ${BOOST_VERSION}
CONFIG+=" 'boost_cflags%': $(quote_flags $(mason cflags boost ${BOOST_VERSION})),"$LN
fi
print_default_flags
if [ ! -z ${BOOST_PROGRAM_OPTIONS_VERSION} ]; then
mason install boost_libprogram_options ${BOOST_PROGRAM_OPTIONS_VERSION}
CONFIG+=" 'boost_program_options_static_libs%': $(quote_flags $(mason static_libs boost_libprogram_options ${BOOST_VERSION})),"$LN
fi
CONFIG+=" },"$LN
CONFIG+=" 'variables': {"$LN
if [ ! -z ${OPENSSL_VERSION} ]; then
mason install openssl ${OPENSSL_VERSION}
CONFIG+=" 'openssl_static_libs%': $(quote_flags $(mason static_libs openssl ${OPENSSL_VERSION})),"$LN
CONFIG+=" 'openssl_cflags%': $(quote_flags $(mason cflags openssl ${OPENSSL_VERSION})),"$LN
CONFIG+=" 'openssl_ldflags%': $(quote_flags $(mason ldflags openssl ${OPENSSL_VERSION})),"$LN
fi
print_opengl_flags
if [ ! -z ${LIBCURL_VERSION} ]; then
mason install libcurl ${LIBCURL_VERSION}
CONFIG+=" 'curl_static_libs%': $(quote_flags $(mason static_libs libcurl ${LIBCURL_VERSION})),"$LN
CONFIG+=" 'curl_cflags%': $(quote_flags $(mason cflags libcurl ${LIBCURL_VERSION})),"$LN
CONFIG+=" 'curl_ldflags%': $(quote_flags $(mason ldflags libcurl ${LIBCURL_VERSION})),"$LN
fi
if [ ! -z ${GLFW_VERSION} ]; then
mason install glfw ${GLFW_VERSION}
CONFIG+=" 'glfw3_static_libs%': $(quote_flags $(mason static_libs glfw ${GLFW_VERSION})),"$LN
CONFIG+=" 'glfw3_cflags%': $(quote_flags $(mason cflags glfw ${GLFW_VERSION})),"$LN
CONFIG+=" 'glfw3_ldflags%': $(quote_flags $(mason ldflags glfw ${GLFW_VERSION})),"$LN
fi
if [ ${MASON_PLATFORM} == 'linux' ]; then
CONFIG+=" 'opengl_cflags%': $(quote_flags $(pkg-config gl x11 --cflags)),"$LN
CONFIG+=" 'opengl_ldflags%': $(quote_flags $(pkg-config gl x11 --libs)),"$LN
else
CONFIG+=" 'opengl_cflags%': $(quote_flags),"$LN
CONFIG+=" 'opengl_ldflags%': $(quote_flags),"$LN
fi
if [ ! -z ${LIBPNG_VERSION} ]; then
mason install libpng ${LIBPNG_VERSION}
CONFIG+=" 'png_static_libs%': $(quote_flags $(mason static_libs libpng ${LIBPNG_VERSION})),"$LN
CONFIG+=" 'png_cflags%': $(quote_flags $(mason cflags libpng ${LIBPNG_VERSION})),"$LN
CONFIG+=" 'png_ldflags%': $(quote_flags $(mason ldflags libpng ${LIBPNG_VERSION})),"$LN
fi
if [ ! -z ${LIBJPEG_VERSION} ]; then
mason install jpeg ${LIBJPEG_VERSION}
CONFIG+=" 'jpeg_static_libs%': $(quote_flags $(mason static_libs jpeg ${LIBJPEG_VERSION})),"$LN
CONFIG+=" 'jpeg_cflags%': $(quote_flags $(mason cflags jpeg ${LIBJPEG_VERSION})),"$LN
CONFIG+=" 'jpeg_ldflags%': $(quote_flags $(mason ldflags jpeg ${LIBJPEG_VERSION})),"$LN
fi
if [ ! -z ${SQLITE_VERSION} ]; then
mason install sqlite ${SQLITE_VERSION}
CONFIG+=" 'sqlite3_static_libs%': $(quote_flags $(mason static_libs sqlite ${SQLITE_VERSION})),"$LN
CONFIG+=" 'sqlite3_cflags%': $(quote_flags $(mason cflags sqlite ${SQLITE_VERSION})),"$LN
CONFIG+=" 'sqlite3_ldflags%': $(quote_flags $(mason ldflags sqlite ${SQLITE_VERSION})),"$LN
fi
if [ ! -z ${LIBUV_VERSION} ]; then
mason install libuv ${LIBUV_VERSION}
CONFIG+=" 'uv_static_libs%': $(quote_flags $(mason static_libs libuv ${LIBUV_VERSION})),"$LN
CONFIG+=" 'uv_cflags%': $(quote_flags $(mason cflags libuv ${LIBUV_VERSION})),"$LN
CONFIG+=" 'uv_ldflags%': $(quote_flags $(mason ldflags libuv ${LIBUV_VERSION})),"$LN
fi
if [ ! -z ${ZLIB_VERSION} ]; then
mason install zlib ${ZLIB_VERSION}
CONFIG+=" 'zlib_static_libs%': $(quote_flags $(mason static_libs zlib ${ZLIB_VERSION})),"$LN
CONFIG+=" 'zlib_cflags%': $(quote_flags $(mason cflags zlib ${ZLIB_VERSION})),"$LN
CONFIG+=" 'zlib_ldflags%': $(quote_flags $(mason ldflags zlib ${ZLIB_VERSION})),"$LN
fi
if [ ! -z ${NUNICODE_VERSION} ]; then
mason install nunicode ${NUNICODE_VERSION}
CONFIG+=" 'nu_static_libs%': $(quote_flags $(mason static_libs nunicode ${NUNICODE_VERSION})),"$LN
CONFIG+=" 'nu_cflags%': $(quote_flags $(mason cflags nunicode ${NUNICODE_VERSION})),"$LN
CONFIG+=" 'nu_ldflags%': $(quote_flags $(mason ldflags nunicode ${NUNICODE_VERSION})),"$LN
fi
if [ ! -z ${LIBZIP_VERSION} ]; then
mason install libzip ${LIBZIP_VERSION}
CONFIG+=" 'zip_static_libs%': $(quote_flags $(mason static_libs libzip ${LIBZIP_VERSION})),"$LN
CONFIG+=" 'zip_cflags%': $(quote_flags $(mason cflags libzip ${LIBZIP_VERSION})),"$LN
CONFIG+=" 'zip_ldflags%': $(quote_flags $(mason ldflags libzip ${LIBZIP_VERSION})),"$LN
fi
print_flags boost cflags
print_flags boost_libprogram_options static_libs
print_flags openssl static_libs cflags ldflags
print_flags libcurl static_libs cflags ldflags
print_flags glfw static_libs cflags ldflags
print_flags libpng static_libs cflags ldflags
print_flags jpeg static_libs cflags ldflags
print_flags sqlite static_libs cflags ldflags
print_flags libuv static_libs cflags ldflags
print_flags zlib static_libs cflags ldflags
print_flags nunicode static_libs cflags ldflags
print_flags libzip static_libs cflags ldflags
CONFIG+=" }
}
"
mkdir -p $(dirname "${CONFIG_FILE}")
echo "${CONFIG}" > ${CONFIG_FILE}
cat ${CONFIG_FILE}

5
gyp/android.gyp Normal file
View File

@@ -0,0 +1,5 @@
{
'includes': [
'../android/mapboxgl-app.gypi',
],
}

View File

@@ -17,14 +17,14 @@
'variables': {
'cflags_cc': [
'<@(uv_cflags)',
'<@(libuv_cflags)',
'<@(boost_cflags)',
],
'ldflags': [
'<@(uv_ldflags)',
'<@(libuv_ldflags)',
],
'libraries': [
'<@(uv_static_libs)',
'<@(libuv_static_libs)',
],
'defines': [
'-DMBGL_ASSET_FS'

View File

@@ -18,21 +18,21 @@
'variables': {
'cflags': [
'<@(uv_cflags)',
'<@(zip_cflags)',
'<@(libuv_cflags)',
'<@(libzip_cflags)',
],
'cflags_cc': [
'<@(uv_cflags)',
'<@(zip_cflags)',
'<@(libuv_cflags)',
'<@(libzip_cflags)',
'<@(boost_cflags)',
],
'ldflags': [
'<@(uv_ldflags)',
'<@(zip_ldflags)',
'<@(libuv_ldflags)',
'<@(libzip_ldflags)',
],
'libraries': [
'<@(uv_static_libs)',
'<@(zip_static_libs)',
'<@(libuv_static_libs)',
'<@(libzip_static_libs)',
],
'defines': [
'-DMBGL_ASSET_ZIP'

View File

@@ -19,17 +19,17 @@
'variables': {
'cflags_cc': [
'<@(uv_cflags)',
'<@(sqlite3_cflags)',
'<@(libuv_cflags)',
'<@(sqlite_cflags)',
],
'ldflags': [
'<@(uv_ldflags)',
'<@(sqlite3_ldflags)',
'<@(libuv_ldflags)',
'<@(sqlite_ldflags)',
'<@(zlib_ldflags)',
],
'libraries': [
'<@(uv_static_libs)',
'<@(sqlite3_static_libs)',
'<@(libuv_static_libs)',
'<@(sqlite_static_libs)',
'<@(zlib_static_libs)',
],
},

View File

@@ -20,6 +20,7 @@
'-Wno-variadic-macros',
'-frtti',
'-fexceptions',
'${CFLAGS}',
],
'GCC_WARN_PEDANTIC': 'YES',
'GCC_WARN_UNINITIALIZED_AUTOS': 'YES_AGGRESSIVE',
@@ -37,6 +38,7 @@
'-Wno-c++1y-extensions',
'-frtti',
'-fexceptions',
'${CFLAGS}',
],
}],
['OS=="linux"', {

View File

@@ -28,21 +28,21 @@
'variables': {
'cflags_cc': [
'<@(uv_cflags)',
'<@(libuv_cflags)',
'<@(opengl_cflags)',
'<@(boost_cflags)',
],
'cflags': [
'<@(uv_cflags)',
'<@(libuv_cflags)',
'<@(opengl_cflags)',
'-fPIC'
],
'ldflags': [
'<@(uv_ldflags)',
'<@(libuv_ldflags)',
'<@(opengl_ldflags)',
],
'libraries': [
'<@(uv_static_libs)',
'<@(libuv_static_libs)',
],
},

View File

@@ -17,17 +17,17 @@
'variables': {
'cflags_cc': [
'<@(uv_cflags)',
'<@(curl_cflags)',
'<@(libuv_cflags)',
'<@(libcurl_cflags)',
'<@(boost_cflags)',
],
'ldflags': [
'<@(uv_ldflags)',
'<@(curl_ldflags)',
'<@(libuv_ldflags)',
'<@(libcurl_ldflags)',
],
'libraries': [
'<@(uv_static_libs)',
'<@(curl_static_libs)',
'<@(libuv_static_libs)',
'<@(libcurl_static_libs)',
],
'defines': [
'-DMBGL_HTTP_CURL'
@@ -38,9 +38,9 @@
['host == "android"', {
'variables': {
# Android uses libzip and openssl to set CURL's CA bundle.
'cflags_cc': [ '<@(zip_cflags)', '<@(openssl_cflags)' ],
'ldflags': [ '<@(zip_ldflags)', ],
'libraries': [ '<@(zip_static_libs)', ],
'cflags_cc': [ '<@(libzip_cflags)', '<@(openssl_cflags)' ],
'ldflags': [ '<@(libzip_ldflags)', ],
'libraries': [ '<@(libzip_static_libs)', ],
},
}],
['OS == "mac"', {

View File

@@ -17,14 +17,14 @@
'variables': {
'cflags_cc': [
'<@(uv_cflags)',
'<@(libuv_cflags)',
],
'ldflags': [
'-framework Foundation', # For NSURLRequest
'<@(uv_ldflags)',
'<@(libuv_ldflags)',
],
'libraries': [
'<@(uv_static_libs)',
'<@(libuv_static_libs)',
],
'defines': [
'-DMBGL_HTTP_NSURL'

View File

@@ -1,7 +1,10 @@
{
'includes': [
'../linux/mapboxgl-app.gypi',
'../test/test.gypi',
'../bin/render.gypi',
],
'conditions': [
['test', { 'includes': [ '../test/test.gypi' ] } ],
['render', { 'includes': [ '../bin/render.gypi' ] } ],
],
}

View File

@@ -22,23 +22,23 @@
'variables': {
'cflags_cc': [
'<@(png_cflags)',
'<@(libpng_cflags)',
'<@(jpeg_cflags)',
'<@(uv_cflags)',
'<@(nu_cflags)',
'<@(libuv_cflags)',
'<@(nunicode_cflags)',
'<@(boost_cflags)',
],
'ldflags': [
'<@(png_ldflags)',
'<@(libpng_ldflags)',
'<@(jpeg_ldflags)',
'<@(uv_ldflags)',
'<@(nu_ldflags)',
'<@(libuv_ldflags)',
'<@(nunicode_ldflags)',
],
'libraries': [
'<@(png_static_libs)',
'<@(libpng_static_libs)',
'<@(jpeg_static_libs)',
'<@(uv_static_libs)',
'<@(nu_static_libs)',
'<@(libuv_static_libs)',
'<@(nunicode_static_libs)',
],
},

View File

@@ -65,11 +65,11 @@
'variables': {
'cflags_cc': [
'<@(uv_cflags)',
'<@(libuv_cflags)',
'<@(boost_cflags)',
],
'libraries': [
'<@(uv_static_libs)',
'<@(libuv_static_libs)',
],
'ldflags': [
'-framework CoreLocation',

View File

@@ -23,23 +23,23 @@
'variables': {
'cflags_cc': [
'<@(png_cflags)',
'<@(libpng_cflags)',
'<@(jpeg_cflags)',
'<@(uv_cflags)',
'<@(nu_cflags)',
'<@(libuv_cflags)',
'<@(nunicode_cflags)',
'<@(boost_cflags)',
],
'ldflags': [
'<@(png_ldflags)',
'<@(libpng_ldflags)',
'<@(jpeg_ldflags)',
'<@(uv_ldflags)',
'<@(nu_ldflags)',
'<@(libuv_ldflags)',
'<@(nunicode_ldflags)',
],
'libraries': [
'<@(png_static_libs)',
'<@(libpng_static_libs)',
'<@(jpeg_static_libs)',
'<@(uv_static_libs)',
'<@(nu_static_libs)',
'<@(libuv_static_libs)',
'<@(nunicode_static_libs)',
],
},

View File

@@ -20,11 +20,11 @@
'variables': {
'cflags_cc': [
'<@(uv_cflags)',
'<@(libuv_cflags)',
'<@(boost_cflags)',
],
'libraries': [
'<@(uv_static_libs)',
'<@(libuv_static_libs)',
],
'ldflags': [
'-framework Foundation',

View File

@@ -31,6 +31,29 @@ extern jfieldID latLngZoomLatitudeId;
extern jfieldID latLngZoomLongitudeId;
extern jfieldID latLngZoomZoomId;
extern jclass markerClass;
extern jmethodID markerConstructorId;
extern jfieldID markerPositionId;
extern jfieldID markerSpriteId;
extern jclass polylineClass;
extern jmethodID polylineConstructorId;
extern jfieldID polylineAlphaId;
extern jfieldID polylineVisibleId;
extern jfieldID polylineColorId;
extern jfieldID polylineWidthId;
extern jfieldID polylinePointsId;
extern jclass polygonClass;
extern jmethodID polygonConstructorId;
extern jfieldID polygonAlphaId;
extern jfieldID polygonVisibleId;
extern jfieldID polygonFillColorId;
extern jfieldID polygonStrokeColorId;
extern jfieldID polygonStrokeWidthId;
extern jfieldID polygonPointsId;
extern jfieldID polygonHolesId;
extern jclass runtimeExceptionClass;
extern jclass nullPointerExceptionClass;

View File

@@ -414,13 +414,24 @@ IB_DESIGNABLE
// Responding to Map Position Changes
// TODO
/** Tells the delegate that the region displayed by the map view is about to change.
*
* This method is called whenever the currently displayed map region will start changing.
* @param mapView The map view whose visible region will change.
* @param animated Whether the change will cause an animated effect on the map. */
- (void)mapView:(MGLMapView *)mapView regionWillChangeAnimated:(BOOL)animated;
// TODO
/** Tells the delegate that the region displayed by the map view is changing.
*
* This method is called whenever the currently displayed map region changes. During movement, this method may be called many times to report updates to the map position. Therefore, your implementation of this method should be as lightweight as possible to avoid affecting performance.
* @param mapView The map view whose visible region is changing. */
- (void)mapViewRegionIsChanging:(MGLMapView *)mapView;
// TODO
/** Tells the delegate that the region displayed by the map view just changed.
*
* This method is called whenever the currently displayed map region has finished changing.
* @param mapView The map view whose visible region changed.
* @param animated Whether the change caused an animated effect on the map. */
- (void)mapView:(MGLMapView *)mapView regionDidChangeAnimated:(BOOL)animated;
#pragma mark - Loading the Map Data

View File

@@ -3,7 +3,7 @@
#include <mbgl/mbgl.hpp>
#ifdef NVIDIA
#ifdef MBGL_USE_GLES2
#define GLFW_INCLUDE_ES2
#endif
#include <GLFW/glfw3.h>

View File

@@ -19,7 +19,7 @@
#else
#error Unsupported Apple platform
#endif
#elif __ANDROID__
#elif __ANDROID__ || MBGL_USE_GLES2
#define GL_GLEXT_PROTOTYPES
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>

View File

@@ -25,21 +25,21 @@ inline void setBlend(const bool& enabled) {
enabled ? MBGL_CHECK_ERROR(glEnable(GL_BLEND)) : MBGL_CHECK_ERROR(glDisable(GL_BLEND));
}
inline std::array<double, 4> getClearColor() {
std::array<double, 4> color;
MBGL_CHECK_ERROR(glGetDoublev(GL_COLOR_CLEAR_VALUE, color.data()));
inline std::array<float, 4> getClearColor() {
std::array<float, 4> color;
MBGL_CHECK_ERROR(glGetFloatv(GL_COLOR_CLEAR_VALUE, color.data()));
return color;
}
inline void setClearColor(const std::array<double, 4>& color) {
inline void setClearColor(const std::array<float, 4>& color) {
MBGL_CHECK_ERROR(glClearColor(color[0], color[1], color[2], color[3]));
}
inline std::array<GLenum, 2> getBlendFunc() {
GLint func[2];
glGetIntegerv(GL_BLEND_SRC, &func[0]);
glGetIntegerv(GL_BLEND_DST, &func[1]);
glGetIntegerv(GL_BLEND_SRC_ALPHA, &func[0]);
glGetIntegerv(GL_BLEND_DST_ALPHA, &func[1]);
return {{ static_cast<GLenum>(func[0]), static_cast<GLenum>(func[1]) }};
}
@@ -47,7 +47,7 @@ inline void setBlendFunc(const std::array<GLenum, 2>& func) {
MBGL_CHECK_ERROR(glBlendFunc(func[0], func[1]));
}
#ifndef GL_ES_VERSION_2_0
inline std::array<double, 2> getPixelZoom() {
std::array<double, 2> zoom;
glGetDoublev(GL_ZOOM_X, &zoom[0]);
@@ -69,17 +69,20 @@ inline std::array<double, 4> getRasterPos() {
inline void setRasterPos(const std::array<double, 4>& pos) {
MBGL_CHECK_ERROR(glRasterPos4d(pos[0], pos[1], pos[2], pos[3]));
}
#endif
} // end anonymous namespace
namespace mbgl {
namespace gl {
using PreserveBlend = Preserve<bool, getBlend, setBlend>;
using PreserveClearColor = Preserve<std::array<double, 4>, getClearColor, setClearColor>;
using PreserveClearColor = Preserve<std::array<float, 4>, getClearColor, setClearColor>;
using PreserveBlendFunc = Preserve<std::array<GLenum, 2>, getBlendFunc, setBlendFunc>;
#ifndef GL_ES_VERSION_2_0
using PreservePixelZoom = Preserve<std::array<double, 2>, getPixelZoom, setPixelZoom>;
using PreserveRasterPos = Preserve<std::array<double, 4>, getRasterPos, setRasterPos>;
#endif
}
}

View File

@@ -33,16 +33,16 @@ public:
static inline double getMetersPerPixelAtLatitude(const double lat, const double zoom) {
const double mapPixelWidthAtZoom = std::pow(2.0, zoom) * util::tileSize;
const double constrainedLatitude = std::fmin(std::fmax(lat, -util::LATITUDE_MAX), util::LATITUDE_MAX);
const double constrainedLatitude = ::fmin(::fmax(lat, -util::LATITUDE_MAX), util::LATITUDE_MAX);
return std::cos(constrainedLatitude * util::DEG2RAD) * util::M2PI * util::EARTH_RADIUS_M / mapPixelWidthAtZoom;
}
static inline const ProjectedMeters projectedMetersForLatLng(const LatLng latLng) {
const double constrainedLatitude = std::fmin(std::fmax(latLng.latitude, -util::LATITUDE_MAX), util::LATITUDE_MAX);
const double constrainedLatitude = ::fmin(::fmax(latLng.latitude, -util::LATITUDE_MAX), util::LATITUDE_MAX);
const double m = 1 - 1e-15;
const double f = std::fmin(std::fmax(std::sin(util::DEG2RAD * constrainedLatitude), -m), m);
const double f = ::fmin(::fmax(std::sin(util::DEG2RAD * constrainedLatitude), -m), m);
const double easting = util::EARTH_RADIUS_M * latLng.longitude * util::DEG2RAD;
const double northing = 0.5 * util::EARTH_RADIUS_M * std::log((1 + f) / (1 - f));
@@ -54,7 +54,7 @@ public:
double latitude = (2 * std::atan(std::exp(projectedMeters.northing / util::EARTH_RADIUS_M)) - (M_PI / 2)) * util::RAD2DEG;
double longitude = projectedMeters.easting * util::RAD2DEG / util::EARTH_RADIUS_M;
latitude = std::fmin(std::fmax(latitude, -util::LATITUDE_MAX), util::LATITUDE_MAX);
latitude = ::fmin(::fmax(latitude, -util::LATITUDE_MAX), util::LATITUDE_MAX);
return LatLng(latitude, longitude);
}

View File

@@ -12,6 +12,8 @@
#include <getopt.h>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <cstdio>
namespace {
@@ -29,11 +31,11 @@ void quit_handler(int) {
}
int main(int argc, char *argv[]) {
int fullscreen_flag = 0;
bool fullscreen = false;
std::string style;
const struct option long_options[] = {
{"fullscreen", no_argument, &fullscreen_flag, 'f'},
{"fullscreen", no_argument, 0, 'f'},
{"style", required_argument, 0, 's'},
{0, 0, 0, 0}
};
@@ -48,7 +50,7 @@ int main(int argc, char *argv[]) {
if (long_options[option_index].flag != 0)
break;
case 'f':
// handle fullscreen_flag
fullscreen = true;
break;
case 's':
style = std::string("asset://") + std::string(optarg);
@@ -65,7 +67,7 @@ int main(int argc, char *argv[]) {
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
view = std::make_unique<GLFWView>();
view = std::make_unique<GLFWView>(fullscreen);
mbgl::SQLiteCache cache("/tmp/mbgl-cache.db");
mbgl::DefaultFileSource fileSource(&cache);

View File

@@ -29,13 +29,15 @@
'variables' : {
'cflags_cc': [
'<@(glfw3_cflags)',
'<@(opengl_cflags)',
'<@(boost_cflags)',
'<@(glfw_cflags)',
],
'ldflags': [
'<@(glfw3_ldflags)',
'<@(glfw_ldflags)',
],
'libraries': [
'<@(glfw3_static_libs)',
'<@(glfw_static_libs)',
],
},

View File

@@ -34,14 +34,15 @@
'variables' : {
'cflags_cc': [
'<@(glfw3_cflags)',
'<@(boost_cflags)',
'<@(glfw_cflags)',
],
'ldflags': [
'-framework SystemConfiguration', # For NSUserDefaults and Reachability
'<@(glfw3_ldflags)',
'<@(glfw_ldflags)',
],
'libraries': [
'<@(glfw3_static_libs)',
'<@(glfw_static_libs)',
],
},

View File

@@ -4,6 +4,7 @@
#include <mbgl/util/util.hpp>
#include <mbgl/util/url.hpp>
#include <mbgl/util/uv.hpp>
#include <mbgl/util/string.hpp>
#include <uv.h>
@@ -131,7 +132,7 @@ void AssetRequest::fileStated(uv_fs_t *req) {
#else
self->response->modified = stat->st_mtime;
#endif
self->response->etag = std::to_string(stat->st_ino);
self->response->etag = util::toString(stat->st_ino);
const auto size = (unsigned int)(stat->st_size);
self->response->data.resize(size);
self->buffer = uv_buf_init(const_cast<char *>(self->response->data.data()), size);

View File

@@ -5,6 +5,7 @@
#include <mbgl/platform/gl.hpp>
#include <mbgl/platform/log.hpp>
#include <mbgl/util/gl_helper.hpp>
#include <mbgl/util/string.hpp>
#include <cassert>
#include <cstdlib>
@@ -188,7 +189,7 @@ void GLFWView::addRandomCustomPointAnnotations(int count) {
for (int i = 0; i < count; i++) {
static int spriteID = 1;
const auto name = std::string{ "marker-" } + std::to_string(spriteID++);
const auto name = std::string{ "marker-" } + mbgl::util::toString(spriteID++);
map->setSprite(name, makeSpriteImage(22, 22, 1));
spriteIDs.push_back(name);
points.emplace_back(makeRandomPoint(), name);

View File

@@ -7,6 +7,7 @@
#include <mbgl/util/time.hpp>
#include <mbgl/util/util.hpp>
#include <mbgl/util/string.hpp>
#include <curl/curl.h>
@@ -20,6 +21,7 @@
#include <map>
#include <cassert>
#include <cstring>
#include <cstdio>
void handleError(CURLMcode code) {
if (code != CURLM_OK) {
@@ -468,7 +470,11 @@ HTTPCURLRequest::HTTPCURLRequest(HTTPCURLContext* context_, const Resource& reso
handleError(curl_easy_setopt(handle, CURLOPT_WRITEDATA, this));
handleError(curl_easy_setopt(handle, CURLOPT_HEADERFUNCTION, headerCallback));
handleError(curl_easy_setopt(handle, CURLOPT_HEADERDATA, this));
#if LIBCURL_VERSION_NUM >= ((7) << 16 | (21) << 8 | 6) // Renamed in 7.21.6
handleError(curl_easy_setopt(handle, CURLOPT_ACCEPT_ENCODING, "gzip, deflate"));
#else
handleError(curl_easy_setopt(handle, CURLOPT_ENCODING, "gzip, deflate"));
#endif
handleError(curl_easy_setopt(handle, CURLOPT_USERAGENT, "MapboxGL/1.0"));
handleError(curl_easy_setopt(handle, CURLOPT_SHARE, context->share));
@@ -700,12 +706,12 @@ void HTTPCURLRequest::handleResult(CURLcode code) {
} else if (responseCode >= 500 && responseCode < 600) {
// Server errors may be temporary, so back off exponentially.
response->status = Response::Error;
response->message = "HTTP status code " + std::to_string(responseCode);
response->message = "HTTP status code " + util::toString(responseCode);
return finish(ResponseStatus::TemporaryError);
} else {
// We don't know how to handle any other errors, so declare them as permanently failing.
response->status = Response::Error;
response->message = "HTTP status code " + std::to_string(responseCode);
response->message = "HTTP status code " + util::toString(responseCode);
return finish(ResponseStatus::PermanentError);
}
}

View File

@@ -157,7 +157,12 @@ void PngReader<T>::read(unsigned x0, unsigned y0, unsigned w, unsigned h, char *
double gamma;
if (png_get_gAMA(png_ptr, info_ptr, &gamma))
png_set_gamma(png_ptr, 2.2, gamma);
#ifdef PNG_ALPHA_PREMULTIPLIED
png_set_alpha_mode(png_ptr, PNG_ALPHA_PREMULTIPLIED, PNG_GAMMA_LINEAR);
#else
// TODO: Manually premultiply the image data.
#endif
if (x0 == 0 && y0 == 0 && w >= width_ && h >= height_)
{

View File

@@ -3,6 +3,7 @@
#include <cassert>
#include <cstring>
#include <cstdio>
// Check sqlite3 library version.
const static bool sqliteVersionCheck = []() {

View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
BOOST_VERSION=1.57.0
LIBCURL_VERSION=7.40.0
OPENSSL_VERSION=1.0.1l
LIBPNG_VERSION=1.6.16
JPEG_VERSION=v9a
SQLITE_VERSION=3.8.8.1
LIBUV_VERSION=1.4.0
ZLIB_VERSION=system
NUNICODE_VERSION=1.5.1
LIBZIP_VERSION=0.11.2
export MASON_ANDROID_ABI=${MASON_PLATFORM_VERSION}

View File

@@ -0,0 +1,11 @@
HEADLESS ?= none
PLATFORM ?= android
ASSET ?= zip
HTTP ?= curl
CACHE ?= sqlite
GYP_FLAVOR_SUFFIX=-android
HOST_VERSION ?= arm-v7
ENV = $(shell MASON_ANDROID_ABI=$(HOST_VERSION) ./scripts/android/toolchain.sh)

6
scripts/ios/configure.sh Normal file
View File

@@ -0,0 +1,6 @@
#!/usr/bin/env bash
BOOST_VERSION=1.57.0
SQLITE_VERSION=system
LIBUV_VERSION=0.10.28
ZLIB_VERSION=system

12
scripts/ios/defaults.mk Normal file
View File

@@ -0,0 +1,12 @@
HEADLESS = none
PLATFORM ?= ios
ASSET ?= fs
HTTP ?= nsurl
CACHE ?= sqlite
HOST_VERSION = all
PROVISIONING_PROFILE ?= 19324a54-7455-4f0b-8e1c-e6957c718ebc
export MASON_PLATFORM=$(HOST)
export MASON_PLATFORM_VERSION=$(HOST_VERSION)

View File

@@ -50,7 +50,7 @@ if [[ "${BUILD_FOR_DEVICE}" == true ]]; then
ARCHS="arm64 armv7 armv7s" \
ONLY_ACTIVE_ARCH=NO \
GCC_GENERATE_DEBUGGING_SYMBOLS=${GCC_GENERATE_DEBUGGING_SYMBOLS} \
-project ./build/ios/mbgl.xcodeproj \
-project ./build/ios-all/mbgl.xcodeproj \
-configuration ${BUILDTYPE} \
-target everything \
-jobs ${JOBS} | xcpretty -c
@@ -61,7 +61,7 @@ xcodebuild -sdk iphonesimulator${IOS_SDK_VERSION} \
ARCHS="x86_64 i386" \
ONLY_ACTIVE_ARCH=NO \
GCC_GENERATE_DEBUGGING_SYMBOLS=${GCC_GENERATE_DEBUGGING_SYMBOLS} \
-project ./build/ios/mbgl.xcodeproj \
-project ./build/ios-all/mbgl.xcodeproj \
-configuration ${BUILDTYPE} \
-target everything \
-jobs ${JOBS} | xcpretty -c

View File

@@ -0,0 +1,18 @@
#!/usr/bin/env bash
BOOST_VERSION=1.57.0
BOOST_LIBPROGRAM_OPTIONS_VERSION=1.57.0
LIBCURL_VERSION=system
GLFW_VERSION=3.1
LIBPNG_VERSION=1.6.16
JPEG_VERSION=v9a
SQLITE_VERSION=3.8.8.1
LIBUV_VERSION=0.10.28
ZLIB_VERSION=system
NUNICODE_VERSION=1.5.1
LIBZIP_VERSION=0.11.2
function print_opengl_flags {
CONFIG+=" 'opengl_cflags%': $(quote_flags $(pkg-config gl x11 --cflags)),"$LN
CONFIG+=" 'opengl_ldflags%': $(quote_flags $(pkg-config gl x11 --libs)),"$LN
}

View File

@@ -0,0 +1,5 @@
HEADLESS ?= glx
PLATFORM ?= linux
ASSET ?= fs
HTTP ?= curl
CACHE ?= sqlite

127
scripts/main.mk Normal file
View File

@@ -0,0 +1,127 @@
ifeq (,$(V))
QUIET = @
endif
# Determine host platform
HOST ?= $(BUILD)
# Defines host defaults
include scripts/$(HOST)/defaults.mk
HOST_VERSION ?= $(BUILD_VERSION)
# Optionally include version-specific host defaults
-include scripts/$(HOST)/$(HOST_VERSION)/defaults.mk
export MASON_PLATFORM=$(HOST)
export MASON_PLATFORM_VERSION=$(HOST_VERSION)
HOST_SLUG = $(HOST)-$(HOST_VERSION)
CONFIGURE_FILES = scripts/$(HOST)/configure.sh
ifneq (,$(wildcard scripts/$(HOST)/$(HOST_VERSION)/configure.sh))
CONFIGURE_FILES += scripts/$(HOST)/$(HOST_VERSION)/configure.sh
endif
# Text formatting
TEXT_BOLD = \033[1m
COLOR_GREEN = \033[32m
COLOR_CYAN = \033[36m
COLOR_PINK = \033[35m
FORMAT_END = \033[0m
default: ;
#### Dependencies ##############################################################
SUBMODULES += .mason/mason.sh
.mason/mason.sh:
./scripts/flock.py .git/Submodule.lock git submodule update --init .mason
SUBMODULES += styles/styles
styles/styles:
./scripts/flock.py .git/Submodule.lock git submodule update --init styles
SUBMODULES += src/mbgl/util/geojsonvt/geojsonvt.hpp
src/mbgl/util/geojsonvt/geojsonvt.hpp:
./scripts/flock.py .git/Submodule.lock git submodule update --init src/mbgl/util/geojsonvt
SUBMODULES += test/suite/package.json
test/suite/package.json:
./scripts/flock.py .git/Submodule.lock git submodule update --init test/suite
ifeq ($(HOST),ios)
SUBMODULES += platform/ios/vendor/SMCalloutView/SMCalloutView.h
platform/ios/vendor/SMCalloutView/SMCalloutView.h:
./scripts/flock.py .git/Submodule.lock git submodule update --init platform/ios/vendor/SMCalloutView
SUBMODULES += test/ios/KIF/KIF.xcodeproj
test/ios/KIF/KIF.xcodeproj:
./scripts/flock.py .git/Submodule.lock git submodule update --init test/ios/KIF
endif
# Wildcard targets get removed after build by default, but we want to preserve the config.
.PRECIOUS: config/%.gypi
config/%.gypi: $(SUBMODULES) configure $(CONFIGURE_FILES)
@printf "$(TEXT_BOLD)$(COLOR_GREEN)* Recreating project...$(FORMAT_END)\n"
$(QUIET)$(ENV) ./scripts/flock.py build/Configure.lock ./configure config/$*.gypi
#### Build files ###############################################################
GYP_FLAGS += -Dhost=$(HOST)
GYP_FLAGS += -Iconfig/$(HOST_SLUG).gypi
GYP_FLAGS += -Dplatform_lib=$(PLATFORM)
GYP_FLAGS += -Dhttp_lib=$(HTTP)
GYP_FLAGS += -Dasset_lib=$(ASSET)
GYP_FLAGS += -Dcache_lib=$(CACHE)
GYP_FLAGS += -Dheadless_lib=$(HEADLESS)
GYP_FLAGS += -Dtest=$(BUILD_TEST)
GYP_FLAGS += -Drender=$(BUILD_RENDER)
GYP_FLAGS += --depth=.
GYP_FLAGS += -Goutput_dir=.
GYP_FLAGS += --generator-output=./build/$(HOST_SLUG)
.PHONY: Makefile/__project__
Makefile/__project__: print-env $(SUBMODULES) config/$(HOST_SLUG).gypi
@printf "$(TEXT_BOLD)$(COLOR_GREEN)* Recreating project...$(FORMAT_END)\n"
$(QUIET)$(ENV) deps/run_gyp gyp/$(HOST).gyp $(GYP_FLAGS) -f make$(GYP_FLAVOR_SUFFIX)
.PHONY: Xcode/__project__
Xcode/__project__: print-env $(SUBMODULES) config/$(HOST_SLUG).gypi
@printf "$(TEXT_BOLD)$(COLOR_GREEN)* Recreating project...$(FORMAT_END)\n"
$(QUIET)$(ENV) deps/run_gyp gyp/$(HOST).gyp $(GYP_FLAGS) -f xcode$(GYP_FLAVOR_SUFFIX)
#### Build individual targets ##################################################
Makefile/%: Makefile/__project__
@printf "$(TEXT_BOLD)$(COLOR_GREEN)* Building target $*...$(FORMAT_END)\n"
$(QUIET)$(ENV) $(MAKE) -C build/$(HOST_SLUG) BUILDTYPE=$(BUILDTYPE) $*
Xcode/%: Xcode/__project__
@printf "$(TEXT_BOLD)$(COLOR_GREEN)* Building target $*...$(FORMAT_END)\n"
$(QUIET)$(ENV) xcodebuild \
$(XCODEBUILD_ARGS) \
-project ./build/$(HOST_SLUG)/gyp/$(HOST).xcodeproj \
-configuration $(BUILDTYPE) \
-target $* \
-jobs $(JOBS) \
$(XCPRETTY)
#### Run tests #################################################################
test-%: Makefile/test
./scripts/run_tests.sh "build/$(HOST_SLUG)/$(BUILDTYPE)/test" --gtest_filter=$*
#### Helper targets ############################################################
.PHONY: print-env
print-env: $(SUBMODULES)
@printf "$(COLOR_PINK)build:$(FORMAT_END) $(BUILD)/$(BUILD_VERSION)\n"
@printf "$(COLOR_PINK)host:$(FORMAT_END) $(HOST)/$(HOST_VERSION)\n"
@printf "$(COLOR_PINK)libs:$(FORMAT_END) "
@printf "headless=$(COLOR_CYAN)%s$(FORMAT_END) " $(HEADLESS)
@printf "platform=$(COLOR_CYAN)%s$(FORMAT_END) " $(PLATFORM)
@printf "asset=$(COLOR_CYAN)%s$(FORMAT_END) " $(ASSET)
@printf "http=$(COLOR_CYAN)%s$(FORMAT_END) " $(HTTP)
@printf "cache=$(COLOR_CYAN)%s$(FORMAT_END)\n" $(CACHE)

13
scripts/osx/configure.sh Normal file
View File

@@ -0,0 +1,13 @@
#!/usr/bin/env bash
BOOST_VERSION=1.57.0
BOOST_LIBPROGRAM_OPTIONS_VERSION=1.57.0
LIBCURL_VERSION=system
GLFW_VERSION=3.1
LIBPNG_VERSION=1.6.16
JPEG_VERSION=v9a
SQLITE_VERSION=3.8.8.1
LIBUV_VERSION=0.10.28
ZLIB_VERSION=system
NUNICODE_VERSION=1.5.1
LIBZIP_VERSION=0.11.2

5
scripts/osx/defaults.mk Normal file
View File

@@ -0,0 +1,5 @@
HEADLESS ?= cgl
PLATFORM ?= osx
ASSET ?= fs
HTTP ?= nsurl
CACHE ?= sqlite

View File

@@ -116,7 +116,7 @@ const size_t namedColorCount = sizeof (namedColors) / sizeof (NamedColor);
template <typename T>
uint8_t clamp_css_byte(T i) { // Clamp to integer 0 .. 255.
i = std::round(i); // Seems to be what Chrome does (vs truncation).
i = ::round(i); // Seems to be what Chrome does (vs truncation).
return i < 0 ? 0 : i > 255 ? 255 : i;
}

View File

@@ -13,8 +13,8 @@ size_t CollisionBoxVertexBuffer::add(int16_t x, int16_t y, float ox, float oy, f
int16_t *shorts = static_cast<int16_t *>(data);
shorts[0] /* pos */ = x;
shorts[1] /* pos */ = y;
shorts[2] /* offset */ = std::round(ox); // use 1/64 pixels for placement
shorts[3] /* offset */ = std::round(oy);
shorts[2] /* offset */ = ::round(ox); // use 1/64 pixels for placement
shorts[3] /* offset */ = ::round(oy);
uint8_t *ubytes = static_cast<uint8_t *>(data);
// a_data1

View File

@@ -23,8 +23,8 @@ void DebugFontBuffer::addText(const char *text, double left, double baseline, do
if (glyph.data[j] == -1 && glyph.data[j + 1] == -1) {
prev = false;
} else {
int16_t x = std::round(left + glyph.data[j] * scale);
int16_t y = std::round(baseline - glyph.data[j + 1] * scale);
int16_t x = ::round(left + glyph.data[j] * scale);
int16_t y = ::round(baseline - glyph.data[j + 1] * scale);
if (prev) {
coords = static_cast<uint16_t *>(addElement());
coords[0] = prev_x;

View File

@@ -13,8 +13,8 @@ size_t IconVertexBuffer::add(int16_t x, int16_t y, float ox, float oy, int16_t t
int16_t *shorts = static_cast<int16_t *>(data);
shorts[0] /* pos */ = x;
shorts[1] /* pos */ = y;
shorts[2] /* offset */ = std::round(ox * 64); // use 1/64 pixels for placement
shorts[3] /* offset */ = std::round(oy * 64);
shorts[2] /* offset */ = ::round(ox * 64); // use 1/64 pixels for placement
shorts[3] /* offset */ = ::round(oy * 64);
uint8_t *ubytes = static_cast<uint8_t *>(data);
// a_data1
@@ -24,7 +24,7 @@ size_t IconVertexBuffer::add(int16_t x, int16_t y, float ox, float oy, int16_t t
// a_data2
ubytes[12] /* minzoom */ = minzoom * 10; // 1/10 zoom levels: z16 == 160.
ubytes[13] /* maxzoom */ = std::fmin(maxzoom, 25) * 10; // 1/10 zoom levels: z16 == 160.
ubytes[13] /* maxzoom */ = ::fmin(maxzoom, 25) * 10; // 1/10 zoom levels: z16 == 160.
return idx;
}

View File

@@ -14,8 +14,8 @@ size_t LineVertexBuffer::add(vertex_type x, vertex_type y, float ex, float ey, i
coords[1] = (y * 2) | ty;
int8_t *extrude = static_cast<int8_t *>(data);
extrude[4] = std::round(extrudeScale * ex);
extrude[5] = std::round(extrudeScale * ey);
extrude[4] = ::round(extrudeScale * ex);
extrude[5] = ::round(extrudeScale * ey);
extrude[6] = static_cast<int8_t>(linesofar / 128);
extrude[7] = static_cast<int8_t>(linesofar % 128);

View File

@@ -13,8 +13,8 @@ size_t TextVertexBuffer::add(int16_t x, int16_t y, float ox, float oy, uint16_t
int16_t *shorts = static_cast<int16_t *>(data);
shorts[0] /* pos */ = x;
shorts[1] /* pos */ = y;
shorts[2] /* offset */ = std::round(ox * 64); // use 1/64 pixels for placement
shorts[3] /* offset */ = std::round(oy * 64);
shorts[2] /* offset */ = ::round(ox * 64); // use 1/64 pixels for placement
shorts[3] /* offset */ = ::round(oy * 64);
uint8_t *ubytes = static_cast<uint8_t *>(data);
// a_data1
@@ -24,7 +24,7 @@ size_t TextVertexBuffer::add(int16_t x, int16_t y, float ox, float oy, uint16_t
// a_data2
ubytes[12] /* minzoom */ = minzoom * 10; // 1/10 zoom levels: z16 == 160.
ubytes[13] /* maxzoom */ = std::fmin(maxzoom, 25) * 10; // 1/10 zoom levels: z16 == 160.
ubytes[13] /* maxzoom */ = ::fmin(maxzoom, 25) * 10; // 1/10 zoom levels: z16 == 160.
return idx;
}

View File

@@ -6,6 +6,8 @@
#include <mbgl/util/constants.hpp>
#include <mbgl/util/geojsonvt/geojsonvt_convert.hpp>
#include <mbgl/util/ptr.hpp>
#include <mbgl/util/string.hpp>
#include <algorithm>
#include <memory>
@@ -66,7 +68,7 @@ uint32_t AnnotationManager::nextID() {
vec2<double> AnnotationManager::projectPoint(const LatLng& point) {
// Clamp to the latitude limits of Mercator.
const double constrainedLatitude = std::fmin(std::fmax(point.latitude, -util::LATITUDE_MAX), util::LATITUDE_MAX);
const double constrainedLatitude = ::fmin(::fmax(point.latitude, -util::LATITUDE_MAX), util::LATITUDE_MAX);
// Project a coordinate into unit space in a square map.
const double sine = std::sin(constrainedLatitude * M_PI / 180.0);
@@ -109,7 +111,7 @@ AnnotationManager::addTileFeature(const uint32_t annotationID,
std::vector<LonLat> points;
for (size_t i = 0; i < segments[0].size(); ++i) { // first segment for now (no holes)
const double constraintedLatitude = std::fmin(std::fmax(segments[0][i].latitude, -util::LATITUDE_MAX), util::LATITUDE_MAX);
const double constraintedLatitude = ::fmin(::fmax(segments[0][i].latitude, -util::LATITUDE_MAX), util::LATITUDE_MAX);
points.push_back(LonLat(segments[0][i].longitude, constraintedLatitude));
}
@@ -219,7 +221,7 @@ AnnotationManager::addTileFeature(const uint32_t annotationID,
if (type == AnnotationType::Point) {
layerID = PointLayerID;
} else {
layerID = ShapeLayerID + "." + std::to_string(annotationID);
layerID = ShapeLayerID + "." + util::toString(annotationID);
}
if (tile_pos.second || tile_pos.first->second.second->getMutableLayer(layerID) == nullptr) {
layer = std::make_shared<LiveTileLayer>();
@@ -382,7 +384,7 @@ std::unordered_set<TileID, TileID::Hash> AnnotationManager::removeAnnotations(co
// remove shape layer from tiles if relevant
for (auto tile_it = tiles.begin(); tile_it != tiles.end(); ++tile_it) {
if (tile_it->second.first.count(annotationID)) {
tile_it->second.second->removeLayer(ShapeLayerID + "." + std::to_string(annotationID));
tile_it->second.second->removeLayer(ShapeLayerID + "." + util::toString(annotationID));
affectedTiles.insert(tile_it->first);
}
}
@@ -507,7 +509,7 @@ const LiveTile* AnnotationManager::getTile(const TileID& id) {
// create shape tile layers from GeoJSONVT queries
for (auto& tiler_it : shapeTilers) {
const auto annotationID = tiler_it.first;
const std::string layerID = ShapeLayerID + "." + std::to_string(annotationID);
const std::string layerID = ShapeLayerID + "." + util::toString(annotationID);
// check for existing render layer
auto renderLayer = renderTile->getMutableLayer(layerID);

View File

@@ -202,9 +202,9 @@ void Map::fitBounds(AnnotationSegment segment, EdgeInsets padding, const Duratio
// Calculate the zoom level.
double scaleX = (getWidth() - padding.left - padding.right) / size.x;
double scaleY = (getHeight() - padding.top - padding.bottom) / size.y;
double minScale = std::fmin(scaleX, scaleY);
double zoom = std::log2(getScale() * minScale);
zoom = std::fmax(std::fmin(zoom, getMaxZoom()), getMinZoom());
double minScale = ::fmin(scaleX, scaleY);
double zoom = ::log2(getScale() * minScale);
zoom = ::fmax(::fmin(zoom, getMaxZoom()), getMinZoom());
// Calculate the center point of a virtual bounds that is extended in all directions by padding.
vec2<> paddedNEPixel = {

View File

@@ -24,6 +24,7 @@
#include <mbgl/util/worker.hpp>
#include <mbgl/util/texture_pool.hpp>
#include <mbgl/util/exception.hpp>
#include <mbgl/util/string.hpp>
#include <algorithm>
@@ -170,7 +171,7 @@ void MapContext::updateAnnotationTiles(const std::unordered_set<TileID, TileID::
// create (if necessary) layers and buckets for each shape
for (const auto &shapeAnnotationID : annotationManager->getOrderedShapeAnnotations()) {
const std::string shapeLayerID = shapeID + "." + std::to_string(shapeAnnotationID);
const std::string shapeLayerID = shapeID + "." + util::toString(shapeAnnotationID);
const auto layer_it = std::find_if(style->layers.begin(), style->layers.end(),
[&shapeLayerID](util::ptr<StyleLayer> layer) {

View File

@@ -312,7 +312,7 @@ double Source::getZoom(const TransformState& state) const {
int32_t Source::coveringZoomLevel(const TransformState& state) const {
double zoom = getZoom(state);
if (info.type == SourceType::Raster || info.type == SourceType::Video) {
zoom = std::round(zoom);
zoom = ::round(zoom);
} else {
zoom = std::floor(zoom);
}
@@ -407,7 +407,7 @@ bool Source::update(MapData& data,
double zoom = getZoom(transformState);
if (info.type == SourceType::Raster || info.type == SourceType::Video) {
zoom = std::round(zoom);
zoom = ::round(zoom);
} else {
zoom = std::floor(zoom);
}

View File

@@ -101,7 +101,7 @@ void Transform::setLatLng(const LatLng latLng, const Duration& duration) {
}
const double m = 1 - 1e-15;
const double f = std::fmin(std::fmax(std::sin(util::DEG2RAD * latLng.latitude), -m), m);
const double f = ::fmin(::fmax(std::sin(util::DEG2RAD * latLng.latitude), -m), m);
double xn = -latLng.longitude * state.Bc;
double yn = 0.5 * state.Cc * std::log((1 + f) / (1 - f));
@@ -121,7 +121,7 @@ void Transform::setLatLngZoom(const LatLng latLng, const double zoom, const Dura
state.Cc = s / util::M2PI;
const double m = 1 - 1e-15;
const double f = std::fmin(std::fmax(std::sin(util::DEG2RAD * latLng.latitude), -m), m);
const double f = ::fmin(::fmax(std::sin(util::DEG2RAD * latLng.latitude), -m), m);
double xn = -latLng.longitude * state.Bc;
double yn = 0.5 * state.Cc * std::log((1 + f) / (1 - f));

View File

@@ -140,11 +140,11 @@ double TransformState::getMinZoom() const {
double test_y = y;
constrain(test_scale, test_y);
return std::log2(std::fmin(min_scale, test_scale));
return ::log2(::fmin(min_scale, test_scale));
}
double TransformState::getMaxZoom() const {
return std::log2(max_scale);
return ::log2(max_scale);
}

View File

@@ -1,4 +1,5 @@
#include <mbgl/platform/gl.hpp>
#include <mbgl/util/string.hpp>
#include <mutex>
@@ -51,7 +52,7 @@ void checkError(const char *cmd, const char *file, int line) {
default: error = "(unknown)"; break;
}
throw ::mbgl::gl::Error(err, std::string(cmd) + ": Error GL_" + error + " - " + file + ":" + std::to_string(line));
throw ::mbgl::gl::Error(err, std::string(cmd) + ": Error GL_" + error + " - " + file + ":" + util::toString(line));
}
}

View File

@@ -2,6 +2,7 @@
#include <mbgl/util/thread_context.hpp>
#include <cstdio>
#include <cstdarg>
#include <sstream>

View File

@@ -141,7 +141,7 @@ void FillBucket::tessellate() {
for (size_t i = 0; i < vertex_count; ++i) {
if (vertex_indices[i] == TESS_UNDEF) {
vertexBuffer.add(std::round(vertices[i * 2]), std::round(vertices[i * 2 + 1]));
vertexBuffer.add(::round(vertices[i * 2]), ::round(vertices[i * 2 + 1]));
vertex_indices[i] = (TESSindex)total_vertex_count;
total_vertex_count++;
}

View File

@@ -63,8 +63,8 @@ FadeProperties FrameHistory::getFadeProperties(const Duration& duration) {
float startingZ = history.front().z;
const FrameSnapshot lastFrame = history.back();
float endingZ = lastFrame.z;
float lowZ = std::fmin(startingZ, endingZ);
float highZ = std::fmax(startingZ, endingZ);
float lowZ = ::fmin(startingZ, endingZ);
float highZ = ::fmax(startingZ, endingZ);
// Calculate the speed of zooming, and how far it would zoom in terms of zoom levels in one
// duration

View File

@@ -70,7 +70,7 @@ void Painter::renderLine(LineBucket& bucket, const StyleLayer &layer_desc, const
LinePatternPos posB = lineAtlas->getDashPosition(properties.dash_array.to, layout.cap == CapType::Round);
lineAtlas->bind();
float patternratio = std::pow(2.0, std::floor(std::log2(state.getScale())) - id.z) / 8.0 * id.overscaling;
float patternratio = std::pow(2.0, std::floor(::log2(state.getScale())) - id.z) / 8.0 * id.overscaling;
float scaleXA = patternratio / posA.width / properties.dash_line_width / properties.dash_array.fromScale;
float scaleYA = -posA.height / 2.0;
float scaleXB = patternratio / posB.width / properties.dash_line_width / properties.dash_array.toScale;

View File

@@ -448,7 +448,7 @@ template <typename Buffer, typename GroupType>
void SymbolBucket::addSymbols(Buffer &buffer, const SymbolQuads &symbols, float scale, const bool keepUpright, const bool alongLine) {
const float zoom = collision.zoom;
const float placementZoom = std::fmax(std::log(scale) / std::log(2) + zoom, 0);
const float placementZoom = ::fmax(std::log(scale) / std::log(2) + zoom, 0);
for (const auto& symbol : symbols) {
const auto &tl = symbol.tl;

View File

@@ -44,7 +44,7 @@ float CollisionTile::placeFeature(const CollisionFeature &feature) {
if (std::isnan(s1) || std::isnan(s2)) s1 = s2 = 1;
if (std::isnan(s3) || std::isnan(s4)) s3 = s4 = 1;
float collisionFreeScale = std::fmin(std::fmax(s1, s2), std::fmax(s3, s4));
float collisionFreeScale = ::fmin(::fmax(s1, s2), ::fmax(s3, s4));
if (collisionFreeScale > blocking.maxScale) {
// After a box's maxScale the label has shrunk enough that the box is no longer needed to cover it,

View File

@@ -27,8 +27,8 @@ const Shaping FontStack::getShaping(const std::u32string &string, const float ma
// the y offset *should* be part of the font metadata
const int32_t yOffset = -17;
float x = std::round(translate.x * 24); // one em
const float y = std::round(translate.y * 24) + yOffset; // one em
float x = ::round(translate.x * 24); // one em
const float y = ::round(translate.y * 24) + yOffset; // one em
// Loop through all characters of this label and shape.
for (uint32_t chr : string) {

View File

@@ -32,7 +32,7 @@ Anchors resample(const std::vector<Coordinate> &line, const float offset, const
y = util::interpolate(float(a.y), float(b.y), t);
if (x >= 0 && x < 4096 && y >= 0 && y < 4096) {
Anchor anchor(std::round(x), std::round(y), angle, 0.5f, i);
Anchor anchor(::round(x), ::round(y), angle, 0.5f, i);
if (!angleWindowSize || checkMaxAngle(line, anchor, labelLength, angleWindowSize, maxAngle)) {
anchors.push_back(anchor);

View File

@@ -2,6 +2,7 @@
#include <zlib.h>
#include <cstdio>
#include <cstring>
#include <stdexcept>

View File

@@ -1,6 +1,7 @@
#include <mbgl/util/io.hpp>
#include <cstdio>
#include <cerrno>
#include <iostream>
#include <sstream>
#include <fstream>

View File

@@ -27,8 +27,8 @@ typedef const std::function<void(int32_t x0, int32_t x1, int32_t y)> ScanLine;
// scan-line conversion
static void scanSpans(edge e0, edge e1, int32_t ymin, int32_t ymax, ScanLine scanLine) {
double y0 = std::fmax(ymin, std::floor(e1.y0));
double y1 = std::fmin(ymax, std::ceil(e1.y1));
double y0 = ::fmax(ymin, std::floor(e1.y0));
double y1 = ::fmin(ymax, std::ceil(e1.y1));
// sort edges by x-coordinate
if ((e0.x0 == e1.x0 && e0.y0 == e1.y0) ?
@@ -43,8 +43,8 @@ static void scanSpans(edge e0, edge e1, int32_t ymin, int32_t ymax, ScanLine sca
double d0 = e0.dx > 0; // use y + 1 to compute x0
double d1 = e1.dx < 0; // use y + 1 to compute x1
for (int32_t y = y0; y < y1; y++) {
double x0 = m0 * std::fmax(0, std::fmin(e0.dy, y + d0 - e0.y0)) + e0.x0;
double x1 = m1 * std::fmax(0, std::fmin(e1.dy, y + d1 - e1.y0)) + e1.x0;
double x0 = m0 * ::fmax(0, ::fmin(e0.dy, y + d0 - e0.y0)) + e0.x0;
double x1 = m1 * ::fmax(0, ::fmin(e1.dy, y + d1 - e1.y0)) + e1.x0;
scanLine(std::floor(x1), std::ceil(x0), y);
}
}

View File

@@ -1,6 +1,8 @@
#include <mbgl/util/time.hpp>
#include <mbgl/util/uv_detail.hpp>
#include <cstdio>
namespace mbgl {
namespace util {

View File

@@ -94,19 +94,19 @@
'style/sprite.cpp',
],
'libraries': [
'<@(uv_static_libs)',
'<@(sqlite3_static_libs)',
'<@(libuv_static_libs)',
'<@(sqlite_static_libs)',
],
'variables': {
'cflags_cc': [
'<@(uv_cflags)',
'<@(libuv_cflags)',
'<@(opengl_cflags)',
'<@(boost_cflags)',
'<@(sqlite3_cflags)',
'<@(sqlite_cflags)',
],
'ldflags': [
'<@(uv_ldflags)',
'<@(sqlite3_ldflags)',
'<@(libuv_ldflags)',
'<@(sqlite_ldflags)',
],
},
'conditions': [