Skip to content

Commit

Permalink
Merge pull request #691 from openmobilemaps/develop
Browse files Browse the repository at this point in the history
Map-9: Develop
  • Loading branch information
stmitt authored Mar 5, 2025
2 parents 3e984eb + 756c587 commit 4745c45
Show file tree
Hide file tree
Showing 360 changed files with 39,967 additions and 1,958 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/jvm_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Maven build JVM
on:
pull_request:
branches: [ main, develop, release/** ]

jobs:
build:
name: Build JVM Project
uses: UbiqueInnovation/workflows-backend/.github/workflows/mvn_install.yml@main
with:
ref_name: ${{ github.sha }}
checkout_submodules: recursive
parent_pom: jvm/pom.xml
install_apt_packages: "cmake make clang libgl-dev libgles-dev libosmesa6-dev"
use_mvn_central: true
65 changes: 65 additions & 0 deletions .github/workflows/jvm_package_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Maven build and deploy JVM
on:
push:
tags:
- '*'
workflow_dispatch:
inputs:
package_version:
description: 'Custom version to use for maven package. Defaults to `git describe`.'
required: false

jobs:
build:
name: Build JVM package and deploy to Maven repo
# Based on: UbiqueInnovation/workflows-backend/.github/workflows/mvn_package_deploy.yml@feature/alt-deployment-repository
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive

- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'

- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2-

- name: Install build dependency apt packages
run: |
sudo apt install cmake make clang libgl-dev libgles-dev libosmesa6-dev
- name: Create custom artifactory settings.xml
uses: whelk-io/maven-settings-xml-action@9dc09b23833fa9aa7f27b63db287951856f3433d
with:
servers: '[{"id": "ubique-artifactory", "username": "${{ secrets.UB_ARTIFACTORY_USER}}", "password": "${{ secrets.UB_ARTIFACTORY_PASSWORD }}"}]'
repositories: '[{"id" : "ubique-artifactory", "url" : "${{ secrets.UB_ARTIFACTORY_URL }}${{ secrets.UB_ARTIFACTORY_REPO_BACKEND }}"}]'


- name: Set custom VERSION from workflow dispatch input
if: ${{ inputs.package_version }}
run: echo "VERSION=${{ inputs.package_version }}" >> $GITHUB_ENV

- name: Set VERSION with git describe
if: ${{ ! inputs.package_version }}
run: echo "VERSION=$(git describe --tags --always)" >> $GITHUB_ENV

- name: Set version
run: |
set -x
# Strip leading `v` from VERSION
# Replace all characters in `\/:"<>|?*` by `-` in VERSION
VERSION=$(echo "$VERSION" | sed 's/[\/:"<>|?*]/-/g;s/^v//;')
mvn -f jvm/pom.xml versions:set -DnewVersion=$VERSION
mvn -f jvm/pom.xml versions:commit
- name: Build and deploy package
run: mvn -f jvm/pom.xml deploy -DskipTests -DaltDeploymentRepository="ubique-artifactory::${{ secrets.UB_ARTIFACTORY_URL }}${{ secrets.UB_ARTIFACTORY_REPO_BACKEND }}"
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ xcuserdata/

## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
build-*/
DerivedData/
*.moved-aside
*.pbxuser
Expand All @@ -72,4 +73,8 @@ DerivedData/
!default.perspectivev3

## Gcc Patch
/*.gcno
/*.gcno

## clangd
.cache/
compile_commands.json
83 changes: 83 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
cmake_minimum_required(VERSION 3.24.0)
project(mapscore
LANGUAGES CXX
)

####
# mapscore OpenGL "proper", i.e. the C++ implementation without language bindings
####
file(GLOB_RECURSE mapscore_SRC
"shared/*.cpp"
"android/src/main/cpp/graphics/*.cpp"
)

add_library(mapscore STATIC ${mapscore_SRC})

find_package(OpenGL)

target_include_directories(mapscore PRIVATE
external/protozero/protozero/include/
external/vtzero/vtzero/include/
external/earcut/earcut/include/mapbox/
shared/src
shared/src/external/pugixml
shared/src/external/gpc
shared/src/logger
shared/src/graphics
shared/src/graphics/helpers
shared/src/map
shared/src/map/camera
shared/src/map/controls
shared/src/map/coordinates
shared/src/map/layers
shared/src/map/layers/objects
shared/src/map/layers/tiled
shared/src/map/layers/tiled/raster
shared/src/map/layers/tiled/wmts
shared/src/map/layers/tiled/vector
shared/src/map/layers/tiled/vector/geojson
shared/src/map/layers/tiled/vector/geojson/geojsonvt
shared/src/map/layers/tiled/vector/tiles
shared/src/map/layers/tiled/vector/tiles/raster
shared/src/map/layers/tiled/vector/tiles/polygon
shared/src/map/layers/tiled/vector/tiles/line
shared/src/map/layers/tiled/vector/sourcemanagers
shared/src/map/layers/tiled/vector/sublayers
shared/src/map/layers/tiled/vector/sublayers/raster
shared/src/map/layers/tiled/vector/sublayers/line
shared/src/map/layers/tiled/vector/sublayers/polygon
shared/src/map/layers/tiled/vector/sublayers/symbol
shared/src/map/layers/tiled/vector/sublayers/background
shared/src/map/layers/tiled/vector/symbol
shared/src/map/layers/tiled/vector/description
shared/src/map/layers/tiled/vector/parsing
shared/src/map/layers/polygon
shared/src/map/layers/icon
shared/src/map/layers/line
shared/src/map/layers/text
shared/src/map/scheduling
shared/src/utils
android/src/main/cpp
android/src/main/cpp/graphics
android/src/main/cpp/graphics/objects
android/src/main/cpp/graphics/shader
android/src/main/cpp/utils
)
target_include_directories(mapscore PUBLIC
shared/public
external/djinni/support-lib/
external/djinni/support-lib/cpp
)
set_property(
SOURCE shared/src/logger/Logger.cpp
APPEND
PROPERTY COMPILE_DEFINITIONS
$<$<CONFIG:Debug>:LOG_LEVEL=4> # LogTrace
$<$<CONFIG:Release>:LOG_LEVEL=1>) # LogWarning
target_compile_definitions(mapscore PRIVATE OPENMOBILEMAPS_GL=1)
target_compile_features(mapscore PRIVATE cxx_std_20)
target_compile_options(mapscore PRIVATE -Werror -Wno-deprecated -Wno-reorder -fPIC) # fPIC so we can "embed" into shared mapscore_jni
target_link_libraries(mapscore ${OPENGL_LIBRARIES})

add_subdirectory(standalone)
add_subdirectory(jvm)
23 changes: 15 additions & 8 deletions android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,21 @@ include_directories(../bridging/android/jni/graphics/shader)
include_directories(../bridging/android/jni/map)
include_directories(../bridging/android/jni/map/controls)
include_directories(../bridging/android/jni/map/layers)
include_directories(../bridging/android/jni/map/layers/effect)
include_directories(../bridging/android/jni/map/layers/icon)
include_directories(../bridging/android/jni/map/layers/line)
include_directories(../bridging/android/jni/map/layers/objects)
include_directories(../bridging/android/jni/map/layers/polygon)
include_directories(../bridging/android/jni/map/layers/skysphere)
include_directories(../bridging/android/jni/map/layers/text)
include_directories(../bridging/android/jni/map/layers/tiled)
include_directories(../bridging/android/jni/map/layers/tiled/raster)
include_directories(../bridging/android/jni/map/layers/tiled/vector)
include_directories(../bridging/android/jni/map/layers/polygon)
include_directories(../bridging/android/jni/map/layers/icon)
include_directories(../bridging/android/jni/map/layers/line)
include_directories(../bridging/android/jni/map/layers/text)
include_directories(../bridging/android/jni/map/loader)
include_directories(../bridging/android/jni/map/scheduling)
include_directories(../bridging/android/jni/map/coordinates)
include_directories(../bridging/android/jni/map/camera)
include_directories(../bridging/android/jni/utils)
include_directories(../shared/public)
include_directories(../shared/src)
include_directories(../shared/src/external/pugixml)
Expand All @@ -81,7 +84,13 @@ include_directories(../shared/src/map/camera)
include_directories(../shared/src/map/controls)
include_directories(../shared/src/map/coordinates)
include_directories(../shared/src/map/layers)
include_directories(../shared/src/map/layers/effect)
include_directories(../shared/src/map/layers/icon)
include_directories(../shared/src/map/layers/objects)
include_directories(../shared/src/map/layers/polygon)
include_directories(../shared/src/map/layers/line)
include_directories(../shared/src/map/layers/skysphere)
include_directories(../shared/src/map/layers/text)
include_directories(../shared/src/map/layers/tiled)
include_directories(../shared/src/map/layers/tiled/raster)
include_directories(../shared/src/map/layers/tiled/wmts)
Expand All @@ -102,18 +111,16 @@ include_directories(../shared/src/map/layers/tiled/vector/sublayers/background)
include_directories(../shared/src/map/layers/tiled/vector/symbol)
include_directories(../shared/src/map/layers/tiled/vector/description)
include_directories(../shared/src/map/layers/tiled/vector/parsing)
include_directories(../shared/src/map/layers/polygon)
include_directories(../shared/src/map/layers/icon)
include_directories(../shared/src/map/layers/line)
include_directories(../shared/src/map/layers/text)
include_directories(../shared/src/map/scheduling)
include_directories(../shared/src/utils)
include_directories(src/main/cpp)
include_directories(src/main/cpp/graphics)
include_directories(src/main/cpp/graphics/objects)
include_directories(src/main/cpp/graphics/shader)
include_directories(src/main/cpp/utils)
include_directories(src/main/cpp/scheduling)

target_compile_definitions(mapscore PRIVATE OPENMOBILEMAPS_GL=1)

# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
Expand Down
2 changes: 1 addition & 1 deletion android/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ implementation 'com.squareup.okhttp3:okhttp:4.12.0' // used for the default Data

### Initializing the library

To use the library, it needs to be initialized as early as possible, e.g. in the oOnCreate(), of the hosting Application by calling:
To use the library, it needs to be initialized as early as possible, e.g. in the OnCreate(), of the hosting Application by calling:

```kotlin
MapsCore.initialize()
Expand Down
2 changes: 1 addition & 1 deletion android/src/main/cpp/graphics/OpenGlContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <string>
#include <unordered_map>

class OpenGlContext : public RenderingContextInterface, std::enable_shared_from_this<OpenGlContext> {
class OpenGlContext : public RenderingContextInterface, public std::enable_shared_from_this<OpenGlContext> {
public:
OpenGlContext();

Expand Down
23 changes: 22 additions & 1 deletion android/src/main/cpp/graphics/OpenGlHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,28 @@ class OpenGlHelper {
static void checkGlError(const std::string &glOperation) {
int error;
while ((error = glGetError()) != GL_NO_ERROR) {
LogError << "GL ERROR: " << glOperation << " " <<= error;
LogError << "GL ERROR: " << glOperation << " " <<= errorString(error);
}
}

static std::string errorString(GLenum errorCode) {
switch (errorCode) {
case GL_INVALID_ENUM:
return "INVALID_ENUM";
case GL_INVALID_VALUE:
return "INVALID_VALUE";
case GL_INVALID_OPERATION:
return "INVALID_OPERATION";
case GL_STACK_OVERFLOW:
return "STACK_OVERFLOW";
case GL_STACK_UNDERFLOW:
return "STACK_UNDERFLOW";
case GL_OUT_OF_MEMORY:
return "OUT_OF_MEMORY";
case GL_INVALID_FRAMEBUFFER_OPERATION:
return "INVALID_FRAMEBUFFER_OPERATION";
default:
return "UNKNOWN_ERROR(" + std::to_string(errorCode) + ")";
}
}
};
1 change: 1 addition & 0 deletions android/src/main/cpp/graphics/objects/Polygon2dOpenGl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ void Polygon2dOpenGl::render(const std::shared_ptr<::RenderingContextInterface>
}

void Polygon2dOpenGl::drawPolygon(const std::shared_ptr<::RenderingContextInterface> &context, int program, int64_t vpMatrix, int64_t mMatrix, const Vec3D &origin) {
std::lock_guard<std::recursive_mutex> lock(dataMutex);
// Add program to OpenGL environment
glUseProgram(program);

Expand Down
28 changes: 22 additions & 6 deletions android/src/main/cpp/graphics/objects/Quad2dOpenGl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "Quad2dOpenGl.h"
#include "TextureHolderInterface.h"
#include "TextureFilterType.h"
#include <cmath>

Quad2dOpenGl::Quad2dOpenGl(const std::shared_ptr<::ShaderProgramInterface> &shader)
Expand Down Expand Up @@ -37,13 +38,13 @@ void Quad2dOpenGl::clear() {

void Quad2dOpenGl::setIsInverseMasked(bool inversed) { isMaskInversed = inversed; }

void Quad2dOpenGl::setFrame(const Quad3dD &frame, const RectD &textureCoordinates, const Vec3D &origin, bool is3D) {
void Quad2dOpenGl::setFrame(const Quad3dD &frame, const RectD &textureCoordinates, const Vec3D &origin, bool is3d) {
std::lock_guard<std::recursive_mutex> lock(dataMutex);
ready = false;
this->frame = frame;
this->textureCoordinates = textureCoordinates;
this->quadOrigin = origin;
this->is3D = is3D;
this->is3d = is3d;
}

void Quad2dOpenGl::setSubdivisionFactor(int32_t factor) {
Expand All @@ -53,6 +54,11 @@ void Quad2dOpenGl::setSubdivisionFactor(int32_t factor) {
}
}

void Quad2dOpenGl::setMinMagFilter(TextureFilterType filterType) {
std::lock_guard<std::recursive_mutex> lock(dataMutex);
textureFilterType = filterType;
}

void Quad2dOpenGl::setup(const std::shared_ptr<::RenderingContextInterface> &context) {
std::lock_guard<std::recursive_mutex> lock(dataMutex);
if (ready) {
Expand All @@ -79,7 +85,7 @@ void Quad2dOpenGl::computeGeometry(bool texCoordsOnly) {
// Data mutex covered by caller Quad2dOpenGL::setup()
if (subdivisionFactor == 0) {
if (!texCoordsOnly) {
if (is3D) {
if (is3d) {
vertices = {
(float) (1.0 * std::sin(frame.topLeft.y) * std::cos(frame.topLeft.x) - quadOrigin.x),
(float) (1.0 * cos(frame.topLeft.y) - quadOrigin.y),
Expand Down Expand Up @@ -152,8 +158,8 @@ void Quad2dOpenGl::computeGeometry(bool texCoordsOnly) {
if (!texCoordsOnly) {
double x = originX + deltaDX;
double y = originY + deltaDY;
double z = is3D ? originZ + deltaDZ : 0.0;
if (is3D) {
double z = is3d ? originZ + deltaDZ : 0.0;
if (is3d) {
vertices.push_back((float) (1.0 * std::sin(y) * std::cos(x) - quadOrigin.x));
vertices.push_back((float) (1.0 * cos(y) - quadOrigin.y));
vertices.push_back((float) (-1.0 * std::sin(x) * std::sin(y) - quadOrigin.z));
Expand Down Expand Up @@ -206,6 +212,8 @@ void Quad2dOpenGl::prepareGlData(int program) {
vpMatrixHandle = glGetUniformLocation(program, "uvpMatrix");
mMatrixHandle = glGetUniformLocation(program, "umMatrix");
originOffsetHandle = glGetUniformLocation(program, "uOriginOffset");
originHandle = glGetUniformLocation(program, "uOrigin");

glDataBuffersGenerated = true;
}

Expand Down Expand Up @@ -289,7 +297,7 @@ void Quad2dOpenGl::renderAsMask(const std::shared_ptr<::RenderingContextInterfac
render(context, renderPass, vpMatrix, mMatrix, origin, false, screenPixelAsRealMeterFactor);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
}

#include "Logger.h"
void Quad2dOpenGl::render(const std::shared_ptr<::RenderingContextInterface> &context, const RenderPassConfig &renderPass,
int64_t vpMatrix, int64_t mMatrix, const ::Vec3D &origin, bool isMasked,
double screenPixelAsRealMeterFactor) {
Expand Down Expand Up @@ -337,6 +345,9 @@ void Quad2dOpenGl::render(const std::shared_ptr<::RenderingContextInterface> &co
glUniformMatrix4fv(vpMatrixHandle, 1, false, (GLfloat *)vpMatrix);
glUniformMatrix4fv(mMatrixHandle, 1, false, (GLfloat *)mMatrix);
glUniform4f(originOffsetHandle, quadOrigin.x - origin.x, quadOrigin.y - origin.y, quadOrigin.z - origin.z, 0.0);
if (originHandle >= 0) {
glUniform4f(originHandle, origin.x, origin.y, origin.z, 1.0);
}

// Draw the triangles
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
Expand Down Expand Up @@ -364,6 +375,11 @@ void Quad2dOpenGl::prepareTextureDraw(int program) {

// Bind the texture to this unit.
glBindTexture(GL_TEXTURE_2D, (unsigned int)texturePointer);
if (textureFilterType.has_value()) {
GLint filterParam = GL_NEAREST;//*textureFilterType == TextureFilterType::LINEAR ? GL_LINEAR : GL_NEAREST;
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filterParam);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filterParam);
}

// Tell the texture uniform sampler to use this texture in the shader by binding to texture unit 0.
int textureUniformHandle = glGetUniformLocation(program, "textureSampler");
Expand Down
Loading

0 comments on commit 4745c45

Please sign in to comment.