summaryrefslogtreecommitdiff
path: root/platform/android/src/style/sources/custom_geometry_source.hpp
blob: 801f81b089bee718f26f2a54e74d71fa0e23e205 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#pragma once

#include "source.hpp"
#include <mbgl/style/sources/custom_geometry_source.hpp>
#include <mbgl/util/geojson.hpp>
#include <mbgl/tile/tile_id.hpp>
#include "../../geojson/geometry.hpp"
#include "../../geojson/feature.hpp"
#include "../../geojson/feature_collection.hpp"
#include "../../geometry/lat_lng_bounds.hpp"
#include <jni/jni.hpp>

namespace mbgl {
namespace android {

class CustomGeometrySource : public Source {
public:

    static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/sources/CustomGeometrySource"; };

    static jni::Class<CustomGeometrySource> javaClass;

    static void registerNative(jni::JNIEnv&);

    CustomGeometrySource(jni::JNIEnv&, jni::String, jni::Object<>);

    CustomGeometrySource(jni::JNIEnv&, mbgl::style::Source&, AndroidRendererFrontend&);

    ~CustomGeometrySource();

    bool removeFromMap(JNIEnv&, jni::Object<Source>, mbgl::Map&) override;
    void addToMap(JNIEnv&, jni::Object<Source>, mbgl::Map&, AndroidRendererFrontend&) override;

    void fetchTile(const mbgl::CanonicalTileID& tileID);
    void cancelTile(const mbgl::CanonicalTileID& tileID);
    bool isCancelled(jni::jint z, jni::jint x, jni::jint y);
    void startThreads();
    void releaseThreads();
    void setTileData(jni::JNIEnv& env, jni::jint z, jni::jint x, jni::jint y, jni::Object<geojson::FeatureCollection> jf);

    void invalidateTile(jni::JNIEnv& env, jni::jint z, jni::jint x, jni::jint y);
    void invalidateBounds(jni::JNIEnv& env, jni::Object<LatLngBounds> bounds);

    jni::Array<jni::Object<geojson::Feature>> querySourceFeatures(jni::JNIEnv&,
                                                                  jni::Array<jni::Object<>> );

private:
    jni::Object<Source> createJavaPeer(jni::JNIEnv&);

}; // class CustomGeometrySource

} // namespace android
} // namespace mbgl