summaryrefslogtreecommitdiff
path: root/platform/android/src/annotation/multi_point.hpp
blob: 20f1b3eaf23b853ba8dfeca8e65801afd282fa36 (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, const jni::Object<java::util::List>& pointsList) {
      auto jarray = 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, jarray.Get(env, i)));
      }

      return geometry;
  }
};

} // namespace android
} // namespace mbgl