Skip to content

Commit

Permalink
Merge pull request #33 from openmobilemaps/develop
Browse files Browse the repository at this point in the history
Version 1.1.0
  • Loading branch information
simonroesch authored Feb 28, 2021
2 parents 69ee9ce + 61f3920 commit 0c49e48
Show file tree
Hide file tree
Showing 423 changed files with 5,260 additions and 1,482 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/bintray-develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Upload AAR to bintray

on:
push:
branches: [ develop ]

jobs:
build:
name: "Upload AAR to bintray"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Upload
run: cd android; ./gradlew bintrayUpload -PbintrayUser=${{secrets.BINTRAY_USER}} -PbintrayApikey=${{secrets.BINTRAY_APIKEY}} -PbintrayVersionSuffix=-dev-$GITHUB_RUN_NUMBER
21 changes: 21 additions & 0 deletions .github/workflows/bintray.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Upload AAR to bintray

on:
push:
branches: [ main ]

jobs:
build:
name: "Upload AAR to bintray"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Upload
run: cd android; ./gradlew bintrayUpload -PbintrayUser=${{secrets.BINTRAY_USER}} -PbintrayApikey=${{secrets.BINTRAY_APIKEY}}
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "external/djinni"]
path = external/djinni
url = git@github.com:UbiqueInnovation/djinni.git
url = https://github.com/UbiqueInnovation/djinni.git
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PackageDescription
let package = Package(
name: "MapCore",
platforms: [
.iOS(.v10),
.iOS(.v11),
],
products: [
.library(
Expand Down
3 changes: 2 additions & 1 deletion android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
/.gradle
/.idea
*.iml
local.properties
local.properties
.cpp_includes
70 changes: 68 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ buildscript {
dependencies {
classpath "com.android.tools.build:gradle:4.1.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
}
}

Expand All @@ -17,15 +18,17 @@ repositories {

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'

android {
compileSdkVersion 30

defaultConfig {
minSdkVersion 23
targetSdkVersion 30
versionCode 1
versionName "1.0"
versionCode 110
versionName "1.1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
Expand All @@ -50,6 +53,69 @@ android {
}
}
}

buildFeatures {
prefabPublishing true
}

prefab{
mapscore_shared {
headers ".cpp_includes"
}
}
}

task copyHeaders(type: Exec){
commandLine './copy_all_header_files_to_include_folder.sh'
}
preBuild.dependsOn copyHeaders

task androidSourcesJar(type: Jar) {
archiveClassifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
afterEvaluate {
publishing {
publications {
"sdkRelease"(MavenPublication) {
from components.release
groupId 'io.openmobilemaps.mapscore'
artifactId 'mapscore-android'
version android.defaultConfig.versionName + readPropertyWithDefault('bintrayVersionSuffix', '')
artifact androidSourcesJar
}
}
}
}

ext.readProperty = { paramName -> readPropertyWithDefault(paramName, null) }
ext.readPropertyWithDefault = { paramName, defaultValue ->
if (project.hasProperty(paramName)) {
return project.getProperties().get(paramName)
} else {
Properties properties = new Properties()
if (project.rootProject.file('local.properties').exists()) {
properties.load(project.rootProject.file('local.properties').newDataInputStream())
}
if (properties.getProperty(paramName) != null) {
return properties.getProperty(paramName)
} else {
return defaultValue
}
}
}

bintray {
user = readProperty('bintrayUser')
key = readProperty('bintrayApikey')
publications = ['sdkRelease']
publish = true
pkg {
repo = 'openmobilemaps'
name = 'maps-core'
userOrg = 'openmobilemaps'
licenses = ['MPL-2.0']
}
}

dependencies {
Expand Down
6 changes: 6 additions & 0 deletions android/copy_all_header_files_to_include_folder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mkdir .cpp_includes
rm .cpp_includes/*
find src/main/cpp/ -type f -name '*.h' -exec cp {} .cpp_includes/ \;
find ../bridging/android/jni -type f -name '*.h' -exec cp {} .cpp_includes/ \;
find ../shared/public -type f -name '*.h' -exec cp {} .cpp_includes/ \;
find ../shared/src -type f -name '*.h' -exec cp {} .cpp_includes/ \;
14 changes: 10 additions & 4 deletions android/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ and you find the generated .aar library under `build/outputs/aar/`. For developm

<h2>Installation</h2>

Either include the `android` folder as a module in the Android project or moving the generated .aar to e.g. the `app/libs` folder of the project and including it in the project via the apps `build.gradle`:
Either include the `android` folder as a module in the Android project or move the generated .aar to e.g. the `app/libs` folder of the project and include it in the project via the apps `build.gradle`:

```
implementation fileTree(dir: 'libs', include: ['*.aar'])
Expand Down Expand Up @@ -90,7 +90,7 @@ The map needs to be initialized with a `MapConfig`, which specifies the coordina
A standard use-case is to display content from a tile-server as a layer in the map, e.g. one containing data from [OpenStreetMap](https://wiki.openstreetmap.org/). In this example case, the map is a projection in the EPSG:3857 system. Thus the `MapView` is recommended to be initialized with a matching `MapConfig`.

```kotlin
mapView.setupMap(MapConfig(CoordinateSystemFactory.getEpsg3857System(), 500000000.0, 1000.0))
mapView.setupMap(MapConfig(CoordinateSystemFactory.getEpsg3857System()))
```

To display the tiles, a Tiled2dMapRasterLayer must be created with both a Tiled2dMapLayerConfig and the implementation of a TextureLoader.
Expand All @@ -111,8 +111,8 @@ The `LayerConfig` contains the information needed for the layer to compute the v
val layerConfig = object : Tiled2dMapLayerConfig() {
// Defines the bounds of the layer and implicitly the coordinate system used by the layer as well
override fun getBounds(): RectCoord = RectCoord(
Coord(CoordinateSystemIdentifiers.EPSG3857(), -20026376.39, 20048966.10, 0.0),
Coord(CoordinateSystemIdentifiers.EPSG3857(), 20026376.39, -20048966.10, 0.0)
Coord(CoordinateSystemIdentifiers.EPSG3857(), -20037508.34, 20037508.34, 0.0),
Coord(CoordinateSystemIdentifiers.EPSG3857(), 20037508.34, -20037508.34, 0.0)
)

// Pattern to create a tile identifier used internally
Expand Down Expand Up @@ -173,6 +173,12 @@ mapView.getCamera().moveToCenterPositionZoom(
10000000.0, false)
```

In the camera, one can also override the default zoom limits with:
```kotlin
mapView.getCamera().setMinZoom(5000000.0)
mapView.getCamera().setMaxZoom(300.0)
```

## License

This project is licensed under the terms of the MPL 2 license. See the [LICENSE](../LICENSE) file.
1 change: 1 addition & 0 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name='MapsCore'
2 changes: 1 addition & 1 deletion android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ch.ubique.mapscore" />
package="io.openmobilemaps.mapscore" />
1 change: 0 additions & 1 deletion android/src/main/cpp/graphics/OpenGlHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* SPDX-License-Identifier: MPL-2.0
*/


#ifndef MAPSCORE_OPENGLHELPER_H
#define MAPSCORE_OPENGLHELPER_H

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
#include "GraphicsObjectFactoryOpenGl.h"
#include "Line2dOpenGl.h"
#include "Polygon2dOpenGl.h"
#include "Rectangle2dOpenGl.h"
#include "Quad2dOpenGl.h"

std::shared_ptr<Rectangle2dInterface>
GraphicsObjectFactoryOpenGl::createRectangle(const std::shared_ptr<::ShaderProgramInterface> &shader) {
return std::make_shared<Rectangle2dOpenGl>(shader);
std::shared_ptr<Quad2dInterface> GraphicsObjectFactoryOpenGl::createQuad(const std::shared_ptr<::ShaderProgramInterface> &shader) {
return std::make_shared<Quad2dOpenGl>(shader);
}

std::shared_ptr<Line2dInterface>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
* SPDX-License-Identifier: MPL-2.0
*/


#ifndef MAPSDK_GRAPHICSOBJECTFACTORYOPENGL_H
#define MAPSDK_GRAPHICSOBJECTFACTORYOPENGL_H

#include "GraphicsObjectFactoryInterface.h"

class GraphicsObjectFactoryOpenGl : public GraphicsObjectFactoryInterface {

virtual std::shared_ptr<Rectangle2dInterface> createRectangle(const std::shared_ptr<::ShaderProgramInterface> &shader) override;
virtual std::shared_ptr<Quad2dInterface> createQuad(const std::shared_ptr<::ShaderProgramInterface> &shader) override;

virtual std::shared_ptr<Line2dInterface> createLine(const std::shared_ptr<::LineShaderProgramInterface> &lineShader) override;

Expand Down
1 change: 0 additions & 1 deletion android/src/main/cpp/graphics/objects/Line2dOpenGl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* SPDX-License-Identifier: MPL-2.0
*/


#include "Line2dOpenGl.h"
#include <cmath>

Expand Down
1 change: 0 additions & 1 deletion android/src/main/cpp/graphics/objects/Line2dOpenGl.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* SPDX-License-Identifier: MPL-2.0
*/


#ifndef MAPSDK_LINE2DOPENGL_H
#define MAPSDK_LINE2DOPENGL_H

Expand Down
1 change: 0 additions & 1 deletion android/src/main/cpp/graphics/objects/Polygon2dOpenGl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* SPDX-License-Identifier: MPL-2.0
*/


#include "Polygon2dOpenGl.h"
#include "OpenGlHelper.h"

Expand Down
1 change: 0 additions & 1 deletion android/src/main/cpp/graphics/objects/Polygon2dOpenGl.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* SPDX-License-Identifier: MPL-2.0
*/


#ifndef MAPSDK_POLYGON2DOPENGL_H
#define MAPSDK_POLYGON2DOPENGL_H

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,38 @@
* SPDX-License-Identifier: MPL-2.0
*/


#include "Rectangle2dOpenGl.h"
#include "Quad2dOpenGl.h"
#include "OpenGlHelper.h"
#include "TextureHolderInterface.h"

Rectangle2dOpenGl::Rectangle2dOpenGl(const std::shared_ptr<::ShaderProgramInterface> &shader)
Quad2dOpenGl::Quad2dOpenGl(const std::shared_ptr<::ShaderProgramInterface> &shader)
: shaderProgram(shader) {}

bool Rectangle2dOpenGl::isReady() { return ready; }
bool Quad2dOpenGl::isReady() { return ready; }

std::shared_ptr<GraphicsObjectInterface> Rectangle2dOpenGl::asGraphicsObject() { return shared_from_this(); }
std::shared_ptr<GraphicsObjectInterface> Quad2dOpenGl::asGraphicsObject() { return shared_from_this(); }

void Rectangle2dOpenGl::clear() {
void Quad2dOpenGl::clear() {
removeTexture();
ready = false;
}

void Rectangle2dOpenGl::setFrame(const RectD &frame, const RectD &textureCoordinates) {
void Quad2dOpenGl::setFrame(const Quad2dD &frame, const RectD &textureCoordinates) {
this->frame = frame;
this->textureCoordinates = textureCoordinates;
ready = false;
}

void Rectangle2dOpenGl::setup(const std::shared_ptr<::RenderingContextInterface> &context) {
void Quad2dOpenGl::setup(const std::shared_ptr<::RenderingContextInterface> &context) {
if (ready)
return;

float frameZ = 0;
vertexBuffer = {
(float)frame.x,
(float)frame.y,
frameZ,
(float)frame.x,
(float)(frame.y + frame.height),
frameZ,
(float)(frame.x + frame.width),
(float)(frame.y + frame.height),
frameZ,
(float)(frame.x + frame.width),
(float)frame.y,
frameZ,
(float)frame.topLeft.x, (float)frame.topLeft.y, frameZ,
(float)frame.bottomLeft.x, (float)frame.bottomLeft.y, frameZ,
(float)frame.bottomRight.x, (float)frame.bottomRight.y, frameZ,
(float)frame.topRight.x, (float)frame.topRight.y, frameZ,
};
indexBuffer = {
0, 1, 2, 0, 2, 3,
Expand All @@ -63,7 +54,7 @@ void Rectangle2dOpenGl::setup(const std::shared_ptr<::RenderingContextInterface>
ready = true;
}

void Rectangle2dOpenGl::loadTexture(const std::shared_ptr<TextureHolderInterface> &textureHolder) {
void Quad2dOpenGl::loadTexture(const std::shared_ptr<TextureHolderInterface> &textureHolder) {
glGenTextures(1, (unsigned int *)&texturePointer[0]);

if (textureHolder != nullptr) {
Expand All @@ -89,13 +80,13 @@ void Rectangle2dOpenGl::loadTexture(const std::shared_ptr<TextureHolderInterface
}
}

void Rectangle2dOpenGl::removeTexture() {
void Quad2dOpenGl::removeTexture() {
glDeleteTextures(1, &texturePointer[0]);
texturePointer = std::vector<GLuint>(1, 0);
textureLoaded = false;
}

void Rectangle2dOpenGl::adjustTextureCoordinates() {
void Quad2dOpenGl::adjustTextureCoordinates() {
float tMinX = factorWidth * textureCoordinates.x;
float tMaxX = factorWidth * (textureCoordinates.x + textureCoordinates.width);
float tMinY = factorHeight * textureCoordinates.y;
Expand All @@ -104,8 +95,8 @@ void Rectangle2dOpenGl::adjustTextureCoordinates() {
textureBuffer = {tMinX, tMinY, tMinX, tMaxY, tMaxX, tMaxY, tMaxX, tMinY};
}

void Rectangle2dOpenGl::render(const std::shared_ptr<::RenderingContextInterface> &context, const RenderPassConfig &renderPass,
int64_t mvpMatrix) {
void Quad2dOpenGl::render(const std::shared_ptr<::RenderingContextInterface> &context, const RenderPassConfig &renderPass,
int64_t mvpMatrix) {
if (!ready)
return;

Expand Down Expand Up @@ -156,7 +147,7 @@ void Rectangle2dOpenGl::render(const std::shared_ptr<::RenderingContextInterface
glDisable(GL_BLEND);
}

void Rectangle2dOpenGl::prepareTextureDraw(std::shared_ptr<OpenGlContext> &openGLContext, int mProgram) {
void Quad2dOpenGl::prepareTextureDraw(std::shared_ptr<OpenGlContext> &openGLContext, int mProgram) {
int mTextureUniformHandle = glGetUniformLocation(mProgram, "u_Texture");

// Set the active texture unit to texture unit 0.
Expand Down
Loading

0 comments on commit 0c49e48

Please sign in to comment.