summaryrefslogtreecommitdiff
path: root/platform/android/src/annotation/multi_point.hpp
blob: 1a6b945261aa00f7447e992003ab0def23c39e8f (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
#pragma once

#include <mbgl/util/noncopyable.hpp>
#include <jni/jni.hpp>

#include "../geometry/lat_lng.hpp"
#include "../java/util.hpp"

namespace mbgl {
namespace android {

class MultiPoint : protected mbgl::util::noncopyable {

protected:

  template <class Geometry>
  static Geometry toGeometry(JNIEnv& env, jni::Object<java::util::List> pointsList) {
      auto jarray = jni::SeizeLocal(env, java::util::List::toArray<LatLng>(env, pointsList));

      std::size_t size = jarray->Length(env);

      Geometry geometry;
      geometry.reserve(size);

      for (std::size_t i = 0; i < size; i++) {
          geometry.push_back(LatLng::getGeometry(env, *jni::SeizeLocal(env, jarray->Get(env, i))));
      }

      return geometry;
  }
};

} // namespace android
} // namespace mbgl