amap_map_fluttify
This commit is contained in:
67
android/build.gradle
Normal file
67
android/build.gradle
Normal file
@ -0,0 +1,67 @@
|
||||
group 'me.yohom.amap_map_fluttify'
|
||||
version '1.0-SNAPSHOT'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.1.2'
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.allprojects {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion 31
|
||||
|
||||
sourceSets {
|
||||
main.java.srcDirs += 'src/main/kotlin'
|
||||
main.jniLibs.srcDir 'libs'
|
||||
}
|
||||
defaultConfig {
|
||||
minSdkVersion 16
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
lintOptions {
|
||||
disable 'InvalidPackage'
|
||||
}
|
||||
compileOptions {
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
packagingOptions {
|
||||
merge 'res/values/values.xml'
|
||||
merge 'AndroidManifest.xml'
|
||||
merge 'R.txt'
|
||||
merge 'classes.jar'
|
||||
merge 'proguard.txt'
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
consumerProguardFiles "proguard-rules.pro"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
|
||||
implementation 'androidx.annotation:annotation:1.1.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
compileOnly rootProject.findProject(":foundation_fluttify")
|
||||
// flutter plugin dependency
|
||||
|
||||
// sdk dependency
|
||||
api 'com.amap.api:3dmap:9.2.1'
|
||||
}
|
26
android/proguard-rules.pro
vendored
Normal file
26
android/proguard-rules.pro
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
|
||||
# 高德地图混淆规则
|
||||
-keep class com.amap.api.maps.**{*;}
|
||||
-keep class com.autonavi.**{*;}
|
||||
-keep class com.amap.api.trace.**{*;}
|
1
android/settings.gradle
Normal file
1
android/settings.gradle
Normal file
@ -0,0 +1 @@
|
||||
rootProject.name = 'amap_map_fluttify'
|
22
android/src/main/AndroidManifest.xml
Normal file
22
android/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="me.yohom.amap_map_fluttify">
|
||||
|
||||
<!--允许程序打开网络套接字-->
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<!--允许程序设置内置sd卡的写权限-->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<!--允许程序获取网络状态-->
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<!--允许程序访问WiFi网络信息-->
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
|
||||
<!--允许程序读写手机状态和身份-->
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
|
||||
<!--允许程序访问CellID或WiFi热点来获取粗略的位置-->
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
|
||||
<!--如果不加回报 error, Neither user 10426 nor current process has android.permission.WAKE_LOCK., null-->
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
||||
|
||||
<application>
|
||||
<activity android:name="com.amap.api.maps.offlinemap.OfflineMapActivity" />
|
||||
</application>
|
||||
</manifest>
|
@ -0,0 +1,186 @@
|
||||
//////////////////////////////////////////////////////////
|
||||
// GENERATED BY FLUTTIFY. DO NOT EDIT IT.
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
package me.yohom.amap_map_fluttify;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.app.Activity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import io.flutter.embedding.engine.plugins.FlutterPlugin;
|
||||
import io.flutter.embedding.engine.plugins.activity.ActivityAware;
|
||||
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
|
||||
import io.flutter.plugin.common.BinaryMessenger;
|
||||
import io.flutter.plugin.common.MethodCall;
|
||||
import io.flutter.plugin.common.MethodChannel;
|
||||
import io.flutter.plugin.common.PluginRegistry.Registrar;
|
||||
import io.flutter.plugin.common.StandardMethodCodec;
|
||||
import io.flutter.plugin.platform.PlatformViewRegistry;
|
||||
|
||||
import me.yohom.amap_map_fluttify.sub_handler.*;
|
||||
import me.yohom.amap_map_fluttify.sub_handler.custom.SubHandlerCustom;
|
||||
import me.yohom.foundation_fluttify.core.FluttifyMessageCodec;
|
||||
|
||||
import static me.yohom.foundation_fluttify.FoundationFluttifyPluginKt.getEnableLog;
|
||||
import static me.yohom.foundation_fluttify.FoundationFluttifyPluginKt.getHEAP;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
public class AmapMapFluttifyPlugin implements FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware {
|
||||
|
||||
private static List<Map<String, Handler>> handlerMapList;
|
||||
|
||||
// v1 android embedding for compatible
|
||||
public static void registerWith(Registrar registrar) {
|
||||
final MethodChannel channel = new MethodChannel(registrar.messenger(), "me.yohom/amap_map_fluttify", new StandardMethodCodec(new FluttifyMessageCodec()));
|
||||
|
||||
AmapMapFluttifyPlugin plugin = new AmapMapFluttifyPlugin();
|
||||
|
||||
BinaryMessenger messenger = registrar.messenger();
|
||||
PlatformViewRegistry platformViewRegistry = registrar.platformViewRegistry();
|
||||
Activity activity = registrar.activity();
|
||||
|
||||
plugin.messenger = messenger;
|
||||
plugin.platformViewRegistry = platformViewRegistry;
|
||||
|
||||
handlerMapList = new ArrayList<>();
|
||||
handlerMapList.add(SubHandler0.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler1.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler2.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler3.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler4.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler5.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler6.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler7.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler8.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler9.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler10.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler11.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler12.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler13.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler14.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler15.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandlerCustom.instance.getSubHandler(messenger, registrar.activity()));
|
||||
|
||||
channel.setMethodCallHandler(plugin);
|
||||
|
||||
// register platform view
|
||||
platformViewRegistry.registerViewFactory("me.yohom/com.amap.api.maps.offlinemap.DownloadProgressView", new DownloadProgressViewFactory(messenger, activity));
|
||||
platformViewRegistry.registerViewFactory("me.yohom/com.amap.api.maps.TextureMapView", new TextureMapViewFactory(messenger, activity));
|
||||
platformViewRegistry.registerViewFactory("me.yohom/com.amap.api.maps.WearMapView", new WearMapViewFactory(messenger, activity));
|
||||
platformViewRegistry.registerViewFactory("me.yohom/com.amap.api.maps.MapView", new MapViewFactory(messenger, activity));
|
||||
}
|
||||
|
||||
private BinaryMessenger messenger;
|
||||
private PlatformViewRegistry platformViewRegistry;
|
||||
|
||||
// v2 android embedding
|
||||
@Override
|
||||
public void onAttachedToEngine(FlutterPluginBinding binding) {
|
||||
if (getEnableLog()) {
|
||||
Log.d("fluttify-java", "AmapMapFluttifyPlugin::onAttachedToEngine@" + binding);
|
||||
}
|
||||
|
||||
final MethodChannel channel = new MethodChannel(binding.getBinaryMessenger(), "me.yohom/amap_map_fluttify", new StandardMethodCodec(new FluttifyMessageCodec()));
|
||||
|
||||
messenger = binding.getBinaryMessenger();
|
||||
platformViewRegistry = binding.getPlatformViewRegistry();
|
||||
|
||||
handlerMapList = new ArrayList<>();
|
||||
handlerMapList.add(SubHandler0.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler1.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler2.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler3.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler4.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler5.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler6.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler7.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler8.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler9.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler10.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler11.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler12.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler13.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler14.getSubHandler(messenger));
|
||||
handlerMapList.add(SubHandler15.getSubHandler(messenger));
|
||||
|
||||
channel.setMethodCallHandler(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromEngine(FlutterPluginBinding binding) {
|
||||
if (getEnableLog()) {
|
||||
Log.d("fluttify-java", "AmapMapFluttifyPlugin::onDetachedFromEngine@" + binding);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToActivity(ActivityPluginBinding binding) {
|
||||
if (getEnableLog()) {
|
||||
Log.d("fluttify-java", "AmapMapFluttifyPlugin::onAttachedToActivity@" + binding);
|
||||
}
|
||||
Activity activity = binding.getActivity();
|
||||
|
||||
handlerMapList.add(SubHandlerCustom.instance.getSubHandler(messenger, activity));
|
||||
|
||||
// register platform view
|
||||
platformViewRegistry.registerViewFactory("me.yohom/com.amap.api.maps.offlinemap.DownloadProgressView", new DownloadProgressViewFactory(messenger, activity));
|
||||
platformViewRegistry.registerViewFactory("me.yohom/com.amap.api.maps.TextureMapView", new TextureMapViewFactory(messenger, activity));
|
||||
platformViewRegistry.registerViewFactory("me.yohom/com.amap.api.maps.WearMapView", new WearMapViewFactory(messenger, activity));
|
||||
platformViewRegistry.registerViewFactory("me.yohom/com.amap.api.maps.MapView", new MapViewFactory(messenger, activity));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromActivity() {
|
||||
if (getEnableLog()) {
|
||||
Log.d("fluttify-java", "AmapMapFluttifyPlugin::onDetachedFromActivity");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReattachedToActivityForConfigChanges(ActivityPluginBinding binding) {
|
||||
if (getEnableLog()) {
|
||||
Log.d("fluttify-java", "AmapMapFluttifyPlugin::onReattachedToActivityForConfigChanges@" + binding);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromActivityForConfigChanges() {
|
||||
if (getEnableLog()) {
|
||||
Log.d("fluttify-java", "AmapMapFluttifyPlugin::onDetachedFromActivityForConfigChanges");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMethodCall(@NonNull MethodCall methodCall, @NonNull MethodChannel.Result methodResult) {
|
||||
Handler handler = null;
|
||||
for (Map<String, Handler> handlerMap : handlerMapList) {
|
||||
if (handlerMap.containsKey(methodCall.method)) {
|
||||
handler = handlerMap.get(methodCall.method);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (handler != null) {
|
||||
try {
|
||||
handler.call(methodCall.arguments, methodResult);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
methodResult.error(e.getMessage(), null, null);
|
||||
}
|
||||
} else {
|
||||
methodResult.notImplemented();
|
||||
}
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public static interface Handler {
|
||||
void call(Object args, MethodChannel.Result methodResult) throws Exception;
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
//////////////////////////////////////////////////////////
|
||||
// GENERATED BY FLUTTIFY. DO NOT EDIT IT.
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
package me.yohom.amap_map_fluttify;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.util.Log;
|
||||
import android.app.Activity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
import io.flutter.plugin.common.BinaryMessenger;
|
||||
import io.flutter.plugin.common.MethodChannel;
|
||||
import io.flutter.plugin.common.PluginRegistry.Registrar;
|
||||
import io.flutter.plugin.common.StandardMessageCodec;
|
||||
import io.flutter.plugin.common.StandardMethodCodec;
|
||||
import io.flutter.plugin.platform.PlatformView;
|
||||
import io.flutter.plugin.platform.PlatformViewFactory;
|
||||
|
||||
import me.yohom.foundation_fluttify.core.FluttifyMessageCodec;
|
||||
|
||||
import static me.yohom.foundation_fluttify.FoundationFluttifyPluginKt.getHEAP;
|
||||
import static me.yohom.foundation_fluttify.FoundationFluttifyPluginKt.getEnableLog;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
class DownloadProgressViewFactory extends PlatformViewFactory {
|
||||
|
||||
DownloadProgressViewFactory(BinaryMessenger messenger, Activity activity) {
|
||||
super(StandardMessageCodec.INSTANCE);
|
||||
|
||||
this.messenger = messenger;
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
private BinaryMessenger messenger;
|
||||
private Activity activity;
|
||||
|
||||
@Override
|
||||
public PlatformView create(Context context, int id, Object params) {
|
||||
Map<String, Object> __args__ = (Map<String, Object>) params;
|
||||
|
||||
////////////////////////////////初始化AndroidView////////////////////////////////////////
|
||||
|
||||
////////////////////////////////初始化AndroidView////////////////////////////////////////
|
||||
|
||||
com.amap.api.maps.offlinemap.DownloadProgressView view = new com.amap.api.maps.offlinemap.DownloadProgressView(activity);
|
||||
|
||||
// 同时存放viewId和refId的对象, 供后续viewId转refId使用
|
||||
getHEAP().put(String.valueOf(Integer.MAX_VALUE - id), view);
|
||||
getHEAP().put("com.amap.api.maps.offlinemap.DownloadProgressView:" + String.valueOf(System.identityHashCode(view)), view);
|
||||
return new PlatformView() {
|
||||
|
||||
// add to HEAP
|
||||
@Override
|
||||
public View getView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {}
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
//////////////////////////////////////////////////////////
|
||||
// GENERATED BY FLUTTIFY. DO NOT EDIT IT.
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
package me.yohom.amap_map_fluttify;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.util.Log;
|
||||
import android.app.Activity;
|
||||
|
||||
import com.amap.api.maps.AMapOptions;
|
||||
import com.amap.api.maps.model.CameraPosition;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
import io.flutter.plugin.common.BinaryMessenger;
|
||||
import io.flutter.plugin.common.MethodChannel;
|
||||
import io.flutter.plugin.common.PluginRegistry.Registrar;
|
||||
import io.flutter.plugin.common.StandardMessageCodec;
|
||||
import io.flutter.plugin.common.StandardMethodCodec;
|
||||
import io.flutter.plugin.platform.PlatformView;
|
||||
import io.flutter.plugin.platform.PlatformViewFactory;
|
||||
|
||||
import me.yohom.foundation_fluttify.core.FluttifyMessageCodec;
|
||||
|
||||
import static me.yohom.foundation_fluttify.FoundationFluttifyPluginKt.getHEAP;
|
||||
import static me.yohom.foundation_fluttify.FoundationFluttifyPluginKt.getEnableLog;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
class MapViewFactory extends PlatformViewFactory {
|
||||
|
||||
MapViewFactory(BinaryMessenger messenger, Activity activity) {
|
||||
super(StandardMessageCodec.INSTANCE);
|
||||
|
||||
this.messenger = messenger;
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
private BinaryMessenger messenger;
|
||||
private Activity activity;
|
||||
|
||||
@Override
|
||||
public PlatformView create(Context context, int id, Object params) {
|
||||
Map<String, Object> __args__ = (Map<String, Object>) params;
|
||||
|
||||
Integer mapType = (Integer) __args__.get("mapType");
|
||||
Boolean showZoomControl = (Boolean) __args__.get("showZoomControl");
|
||||
Boolean showCompass = (Boolean) __args__.get("showCompass");
|
||||
Boolean showScaleControl = (Boolean) __args__.get("showScaleControl");
|
||||
Boolean zoomGesturesEnabled = (Boolean) __args__.get("zoomGesturesEnabled");
|
||||
Boolean scrollGesturesEnabled = (Boolean) __args__.get("scrollGesturesEnabled");
|
||||
Boolean rotateGestureEnabled = (Boolean) __args__.get("rotateGestureEnabled");
|
||||
Boolean tiltGestureEnabled = (Boolean) __args__.get("tiltGestureEnabled");
|
||||
Double zoomLevel = (Double) __args__.get("zoomLevel");
|
||||
Double tilt = (Double) __args__.get("tilt");
|
||||
Double bearing = (Double) __args__.get("bearing");
|
||||
Double centerCoordinateLatitude = (Double) __args__.get("centerCoordinateLatitude");
|
||||
Double centerCoordinateLongitude = (Double) __args__.get("centerCoordinateLongitude");
|
||||
|
||||
AMapOptions options = new AMapOptions();
|
||||
|
||||
if (mapType != null) options.mapType(mapType + 1);
|
||||
if (showZoomControl != null) options.zoomControlsEnabled(showZoomControl);
|
||||
if (showCompass != null) options.compassEnabled(showCompass);
|
||||
if (showScaleControl != null) options.scaleControlsEnabled(showScaleControl);
|
||||
if (zoomGesturesEnabled != null) options.zoomGesturesEnabled(zoomGesturesEnabled);
|
||||
if (scrollGesturesEnabled != null) options.scrollGesturesEnabled(scrollGesturesEnabled);
|
||||
if (rotateGestureEnabled != null) options.rotateGesturesEnabled(rotateGestureEnabled);
|
||||
if (tiltGestureEnabled != null) options.tiltGesturesEnabled(tiltGestureEnabled);
|
||||
CameraPosition.Builder builder = CameraPosition
|
||||
.builder()
|
||||
.bearing(bearing == null ? 0 : bearing.floatValue())
|
||||
.tilt(tilt == null ? 0 : tilt.floatValue())
|
||||
.zoom(zoomLevel == null ? 0 : zoomLevel.floatValue());
|
||||
if (centerCoordinateLatitude != null && centerCoordinateLongitude != null) {
|
||||
builder.target(new LatLng(centerCoordinateLatitude, centerCoordinateLongitude));
|
||||
}
|
||||
options.camera(builder.build());
|
||||
////////////////////////////////初始化AndroidView////////////////////////////////////////
|
||||
|
||||
com.amap.api.maps.MapView view = new com.amap.api.maps.MapView(activity, options);
|
||||
|
||||
// 同时存放viewId和refId的对象, 供后续viewId转refId使用
|
||||
getHEAP().put(String.valueOf(Integer.MAX_VALUE - id), view);
|
||||
getHEAP().put("com.amap.api.maps.MapView:" + String.valueOf(System.identityHashCode(view)), view);
|
||||
return new PlatformView() {
|
||||
|
||||
// add to HEAP
|
||||
@Override
|
||||
public View getView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {}
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
//////////////////////////////////////////////////////////
|
||||
// GENERATED BY FLUTTIFY. DO NOT EDIT IT.
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
package me.yohom.amap_map_fluttify;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import com.amap.api.maps.AMapOptions;
|
||||
import com.amap.api.maps.model.CameraPosition;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.flutter.plugin.common.BinaryMessenger;
|
||||
import io.flutter.plugin.common.MethodChannel;
|
||||
import io.flutter.plugin.common.StandardMessageCodec;
|
||||
import io.flutter.plugin.common.StandardMethodCodec;
|
||||
import io.flutter.plugin.platform.PlatformView;
|
||||
import io.flutter.plugin.platform.PlatformViewFactory;
|
||||
import me.yohom.foundation_fluttify.core.FluttifyMessageCodec;
|
||||
|
||||
import static me.yohom.foundation_fluttify.FoundationFluttifyPluginKt.getEnableLog;
|
||||
import static me.yohom.foundation_fluttify.FoundationFluttifyPluginKt.getHEAP;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
class TextureMapViewFactory extends PlatformViewFactory {
|
||||
|
||||
TextureMapViewFactory(BinaryMessenger messenger, Activity activity) {
|
||||
super(StandardMessageCodec.INSTANCE);
|
||||
|
||||
this.messenger = messenger;
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
private BinaryMessenger messenger;
|
||||
private Activity activity;
|
||||
|
||||
@Override
|
||||
public PlatformView create(Context context, int id, Object params) {
|
||||
Map<String, Object> __args__ = (Map<String, Object>) params;
|
||||
|
||||
Integer mapType = (Integer) __args__.get("mapType");
|
||||
Boolean showZoomControl = (Boolean) __args__.get("showZoomControl");
|
||||
Boolean showCompass = (Boolean) __args__.get("showCompass");
|
||||
Boolean showScaleControl = (Boolean) __args__.get("showScaleControl");
|
||||
Boolean zoomGesturesEnabled = (Boolean) __args__.get("zoomGesturesEnabled");
|
||||
Boolean scrollGesturesEnabled = (Boolean) __args__.get("scrollGesturesEnabled");
|
||||
Boolean rotateGestureEnabled = (Boolean) __args__.get("rotateGestureEnabled");
|
||||
Boolean tiltGestureEnabled = (Boolean) __args__.get("tiltGestureEnabled");
|
||||
Double zoomLevel = (Double) __args__.get("zoomLevel");
|
||||
Double tilt = (Double) __args__.get("tilt");
|
||||
Double bearing = (Double) __args__.get("bearing");
|
||||
Double centerCoordinateLatitude = (Double) __args__.get("centerCoordinateLatitude");
|
||||
Double centerCoordinateLongitude = (Double) __args__.get("centerCoordinateLongitude");
|
||||
|
||||
AMapOptions options = new AMapOptions();
|
||||
|
||||
if (mapType != null) options.mapType(mapType + 1);
|
||||
if (showZoomControl != null) options.zoomControlsEnabled(showZoomControl);
|
||||
if (showCompass != null) options.compassEnabled(showCompass);
|
||||
if (showScaleControl != null) options.scaleControlsEnabled(showScaleControl);
|
||||
if (zoomGesturesEnabled != null) options.zoomGesturesEnabled(zoomGesturesEnabled);
|
||||
if (scrollGesturesEnabled != null) options.scrollGesturesEnabled(scrollGesturesEnabled);
|
||||
if (rotateGestureEnabled != null) options.rotateGesturesEnabled(rotateGestureEnabled);
|
||||
if (tiltGestureEnabled != null) options.tiltGesturesEnabled(tiltGestureEnabled);
|
||||
CameraPosition.Builder builder = CameraPosition
|
||||
.builder()
|
||||
.bearing(bearing == null ? 0 : bearing.floatValue())
|
||||
.tilt(tilt == null ? 0 : tilt.floatValue())
|
||||
.zoom(zoomLevel == null ? 0 : zoomLevel.floatValue());
|
||||
if (centerCoordinateLatitude != null && centerCoordinateLongitude != null) {
|
||||
builder.target(new LatLng(centerCoordinateLatitude, centerCoordinateLongitude));
|
||||
}
|
||||
options.camera(builder.build());
|
||||
////////////////////////////////初始化AndroidView////////////////////////////////////////
|
||||
|
||||
com.amap.api.maps.TextureMapView view = new com.amap.api.maps.TextureMapView(activity, options);
|
||||
|
||||
// 同时存放viewId和refId的对象, 供后续viewId转refId使用
|
||||
getHEAP().put(String.valueOf(Integer.MAX_VALUE - id), view);
|
||||
getHEAP().put("com.amap.api.maps.TextureMapView:" + String.valueOf(System.identityHashCode(view)), view);
|
||||
return new PlatformView() {
|
||||
|
||||
// add to HEAP
|
||||
@Override
|
||||
public View getView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {}
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
//////////////////////////////////////////////////////////
|
||||
// GENERATED BY FLUTTIFY. DO NOT EDIT IT.
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
package me.yohom.amap_map_fluttify;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.util.Log;
|
||||
import android.app.Activity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
import io.flutter.plugin.common.BinaryMessenger;
|
||||
import io.flutter.plugin.common.MethodChannel;
|
||||
import io.flutter.plugin.common.PluginRegistry.Registrar;
|
||||
import io.flutter.plugin.common.StandardMessageCodec;
|
||||
import io.flutter.plugin.common.StandardMethodCodec;
|
||||
import io.flutter.plugin.platform.PlatformView;
|
||||
import io.flutter.plugin.platform.PlatformViewFactory;
|
||||
|
||||
import me.yohom.foundation_fluttify.core.FluttifyMessageCodec;
|
||||
|
||||
import static me.yohom.foundation_fluttify.FoundationFluttifyPluginKt.getHEAP;
|
||||
import static me.yohom.foundation_fluttify.FoundationFluttifyPluginKt.getEnableLog;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
class WearMapViewFactory extends PlatformViewFactory {
|
||||
|
||||
WearMapViewFactory(BinaryMessenger messenger, Activity activity) {
|
||||
super(StandardMessageCodec.INSTANCE);
|
||||
|
||||
this.messenger = messenger;
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
private BinaryMessenger messenger;
|
||||
private Activity activity;
|
||||
|
||||
@Override
|
||||
public PlatformView create(Context context, int id, Object params) {
|
||||
Map<String, Object> __args__ = (Map<String, Object>) params;
|
||||
|
||||
////////////////////////////////初始化AndroidView////////////////////////////////////////
|
||||
|
||||
////////////////////////////////初始化AndroidView////////////////////////////////////////
|
||||
|
||||
com.amap.api.maps.WearMapView view = new com.amap.api.maps.WearMapView(activity);
|
||||
|
||||
// 同时存放viewId和refId的对象, 供后续viewId转refId使用
|
||||
getHEAP().put(String.valueOf(Integer.MAX_VALUE - id), view);
|
||||
getHEAP().put("com.amap.api.maps.WearMapView:" + String.valueOf(System.identityHashCode(view)), view);
|
||||
return new PlatformView() {
|
||||
|
||||
// add to HEAP
|
||||
@Override
|
||||
public View getView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {}
|
||||
};
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,752 @@
|
||||
//////////////////////////////////////////////////////////
|
||||
// GENERATED BY FLUTTIFY. DO NOT EDIT IT.
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
package me.yohom.amap_map_fluttify.sub_handler.custom;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.amap.api.maps.AMap;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.amap.api.maps.model.Marker;
|
||||
import com.amap.api.maps.utils.PathSmoothTool;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.flutter.plugin.common.BinaryMessenger;
|
||||
import me.yohom.amap_map_fluttify.AmapMapFluttifyPlugin.Handler;
|
||||
import me.yohom.amap_map_fluttify.sub_handler.custom.tile_provider.UrlTileProviderImpl;
|
||||
|
||||
import static me.yohom.foundation_fluttify.FoundationFluttifyPluginKt.getEnableLog;
|
||||
import static me.yohom.foundation_fluttify.FoundationFluttifyPluginKt.getHEAP;
|
||||
import static me.yohom.foundation_fluttify.FoundationFluttifyPluginKt.getSTACK;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
public class SubHandlerCustom {
|
||||
|
||||
public static final SubHandlerCustom instance = new SubHandlerCustom();
|
||||
|
||||
private SubHandlerCustom() { }
|
||||
|
||||
public static Map<String, Handler> getSubHandler(BinaryMessenger messenger, Activity activity) {
|
||||
return new HashMap<String, Handler>() {{
|
||||
put("com.amap.api.maps.AMap::setInfoWindowAdapterX", (__args__, __methodResult__) -> {
|
||||
// ref
|
||||
com.amap.api.maps.AMap __this__ = (com.amap.api.maps.AMap) ((Map<String, Object>) __args__).get("__this__");
|
||||
|
||||
// invoke native method
|
||||
try {
|
||||
__this__.setInfoWindowAdapter(new AMap.InfoWindowAdapter() {
|
||||
@Override
|
||||
public View getInfoWindow(Marker marker) {
|
||||
Bitmap bitmap = (Bitmap) getSTACK().get("infoWindow");
|
||||
ImageView view = new ImageView(activity);
|
||||
view.setBackgroundColor(Color.TRANSPARENT);
|
||||
view.setImageBitmap(bitmap);
|
||||
|
||||
// 调用完成后清空栈
|
||||
getSTACK().clear();
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getInfoContents(Marker marker) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
if (getEnableLog()) {
|
||||
Log.d("Current HEAP: ", getHEAP().toString());
|
||||
}
|
||||
__methodResult__.error(throwable.getMessage(), null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
// convert result to jsonable result
|
||||
String jsonableResult = "success";
|
||||
|
||||
__methodResult__.success(jsonableResult);
|
||||
});
|
||||
put("com.amap.api.maps.model.UrlTileProviderX::create", (__rawArgs__, __methodResult__) -> {
|
||||
Map<String, Object> __args__ = (Map<String, Object>) __rawArgs__;
|
||||
|
||||
final int width = (int) __args__.get("width");
|
||||
final int height = (int) __args__.get("height");
|
||||
final String urlTemplate = (String) __args__.get("urlTemplate");
|
||||
|
||||
try {
|
||||
final UrlTileProviderImpl provider = new UrlTileProviderImpl(width, height, urlTemplate);
|
||||
__methodResult__.success(provider);
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
if (getEnableLog()) {
|
||||
Log.d("Current HEAP: ", getHEAP().toString());
|
||||
}
|
||||
__methodResult__.error(throwable.getMessage(), null, null);
|
||||
return;
|
||||
}
|
||||
});
|
||||
put("ObjectFactory::createcom_amap_api_maps_model_Gradient__intArray__floatArrayX", (__args__, __methodResult__) -> {
|
||||
if (getEnableLog()) {
|
||||
Log.d("ObjectFactory", "创建对象: com_amap_api_maps_model_Gradient__intArray__floatArray");
|
||||
}
|
||||
|
||||
// args
|
||||
// jsonable arg
|
||||
int[] var1 = (int[]) ((Map<String, Object>) __args__).get("var1");
|
||||
// jsonable arg
|
||||
double[] var2 = (double[]) ((Map<String, Object>) __args__).get("var2");
|
||||
|
||||
float[] stopList = new float[var2.length];
|
||||
for (int i = 0; i < var2.length; i++) {
|
||||
stopList[i] = (float) var2[i];
|
||||
}
|
||||
|
||||
// create target object
|
||||
com.amap.api.maps.model.Gradient __obj__ = new com.amap.api.maps.model.Gradient(var1, stopList);
|
||||
|
||||
__methodResult__.success(__obj__);
|
||||
});
|
||||
//region 平滑轨迹
|
||||
// method
|
||||
put("com.amap.api.maps.utils.PathSmoothTool::setIntensity", (__args__, __methodResult__) -> {
|
||||
// args
|
||||
// ref arg
|
||||
Number mIntensity = (Number) ((Map<String, Object>) __args__).get("mIntensity");
|
||||
|
||||
// ref
|
||||
PathSmoothTool __this__ = (PathSmoothTool) ((Map<String, Object>) __args__).get("__this__");
|
||||
|
||||
// print log
|
||||
if (getEnableLog()) {
|
||||
Log.d("fluttify-java", "fluttify-java: com.amap.api.maps.utils.PathSmoothTool@" + __this__ + "::setIntensity(" + mIntensity + ")");
|
||||
}
|
||||
|
||||
// invoke native method
|
||||
Void __result__ = null;
|
||||
try {
|
||||
__this__.setIntensity(mIntensity.intValue());
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
if (getEnableLog()) {
|
||||
Log.d("Current HEAP: ", getHEAP().toString());
|
||||
}
|
||||
__methodResult__.error(throwable.getMessage(), null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
__methodResult__.success(__result__);
|
||||
});
|
||||
// method
|
||||
put("com.amap.api.maps.utils.PathSmoothTool::getThreshhold", (__args__, __methodResult__) -> {
|
||||
// args
|
||||
|
||||
|
||||
// ref
|
||||
PathSmoothTool __this__ = (PathSmoothTool) ((Map<String, Object>) __args__).get("__this__");
|
||||
|
||||
// print log
|
||||
if (getEnableLog()) {
|
||||
Log.d("fluttify-java", "fluttify-java: com.amap.api.maps.utils.PathSmoothTool@" + __this__ + "::getThreshhold(" + "" + ")");
|
||||
}
|
||||
|
||||
// invoke native method
|
||||
Float __result__ = null;
|
||||
try {
|
||||
__result__ = __this__.getThreshhold();
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
if (getEnableLog()) {
|
||||
Log.d("Current HEAP: ", getHEAP().toString());
|
||||
}
|
||||
__methodResult__.error(throwable.getMessage(), null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
__methodResult__.success(__result__);
|
||||
});
|
||||
// method
|
||||
put("com.amap.api.maps.utils.PathSmoothTool::setThreshhold", (__args__, __methodResult__) -> {
|
||||
// args
|
||||
// ref arg
|
||||
Number mThreshhold = (Number) ((Map<String, Object>) __args__).get("mThreshhold");
|
||||
|
||||
// ref
|
||||
PathSmoothTool __this__ = (PathSmoothTool) ((Map<String, Object>) __args__).get("__this__");
|
||||
|
||||
// print log
|
||||
if (getEnableLog()) {
|
||||
Log.d("fluttify-java", "fluttify-java: com.amap.api.maps.utils.PathSmoothTool@" + __this__ + "::setThreshhold(" + mThreshhold + ")");
|
||||
}
|
||||
|
||||
// invoke native method
|
||||
Void __result__ = null;
|
||||
try {
|
||||
__this__.setThreshhold(mThreshhold.floatValue());
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
if (getEnableLog()) {
|
||||
Log.d("Current HEAP: ", getHEAP().toString());
|
||||
}
|
||||
__methodResult__.error(throwable.getMessage(), null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
__methodResult__.success(__result__);
|
||||
});
|
||||
// method
|
||||
put("com.amap.api.maps.utils.PathSmoothTool::setNoiseThreshhold", (__args__, __methodResult__) -> {
|
||||
// args
|
||||
// ref arg
|
||||
Number mnoiseThreshhold = (Number) ((Map<String, Object>) __args__).get("mnoiseThreshhold");
|
||||
|
||||
// ref
|
||||
PathSmoothTool __this__ = (PathSmoothTool) ((Map<String, Object>) __args__).get("__this__");
|
||||
|
||||
// print log
|
||||
if (getEnableLog()) {
|
||||
Log.d("fluttify-java", "fluttify-java: com.amap.api.maps.utils.PathSmoothTool@" + __this__ + "::setNoiseThreshhold(" + mnoiseThreshhold + ")");
|
||||
}
|
||||
|
||||
// invoke native method
|
||||
Void __result__ = null;
|
||||
try {
|
||||
__this__.setNoiseThreshhold(mnoiseThreshhold.floatValue());
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
if (getEnableLog()) {
|
||||
Log.d("Current HEAP: ", getHEAP().toString());
|
||||
}
|
||||
__methodResult__.error(throwable.getMessage(), null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
__methodResult__.success(__result__);
|
||||
});
|
||||
// method
|
||||
put("com.amap.api.maps.utils.PathSmoothTool::pathOptimize", (__args__, __methodResult__) -> {
|
||||
// args
|
||||
// ref arg
|
||||
java.util.List<com.amap.api.maps.model.LatLng> originlist = (java.util.List<com.amap.api.maps.model.LatLng>) ((Map<String, Object>) __args__).get("originlist");
|
||||
|
||||
// ref
|
||||
PathSmoothTool __this__ = (PathSmoothTool) ((Map<String, Object>) __args__).get("__this__");
|
||||
|
||||
// print log
|
||||
if (getEnableLog()) {
|
||||
Log.d("fluttify-java", "fluttify-java: com.amap.api.maps.utils.PathSmoothTool@" + __this__ + "::pathOptimize(" + originlist + ")");
|
||||
}
|
||||
|
||||
// invoke native method
|
||||
java.util.List<com.amap.api.maps.model.LatLng> __result__ = null;
|
||||
try {
|
||||
__result__ = __this__.pathOptimize(originlist);
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
if (getEnableLog()) {
|
||||
Log.d("Current HEAP: ", getHEAP().toString());
|
||||
}
|
||||
__methodResult__.error(throwable.getMessage(), null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
__methodResult__.success(__result__);
|
||||
});
|
||||
// method
|
||||
put("com.amap.api.maps.utils.PathSmoothTool::kalmanFilterPath__List_com_amap_api_maps_model_LatLng_", (__args__, __methodResult__) -> {
|
||||
// args
|
||||
// ref arg
|
||||
java.util.List<com.amap.api.maps.model.LatLng> originlist = (java.util.List<com.amap.api.maps.model.LatLng>) ((Map<String, Object>) __args__).get("originlist");
|
||||
|
||||
// ref
|
||||
PathSmoothTool __this__ = (PathSmoothTool) ((Map<String, Object>) __args__).get("__this__");
|
||||
|
||||
// print log
|
||||
if (getEnableLog()) {
|
||||
Log.d("fluttify-java", "fluttify-java: com.amap.api.maps.utils.PathSmoothTool@" + __this__ + "::kalmanFilterPath(" + originlist + ")");
|
||||
}
|
||||
|
||||
// invoke native method
|
||||
java.util.List<com.amap.api.maps.model.LatLng> __result__ = null;
|
||||
try {
|
||||
__result__ = __this__.kalmanFilterPath(originlist);
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
if (getEnableLog()) {
|
||||
Log.d("Current HEAP: ", getHEAP().toString());
|
||||
}
|
||||
__methodResult__.error(throwable.getMessage(), null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
__methodResult__.success(__result__);
|
||||
});
|
||||
// method
|
||||
put("com.amap.api.maps.utils.PathSmoothTool::removeNoisePoint", (__args__, __methodResult__) -> {
|
||||
// args
|
||||
// ref arg
|
||||
java.util.List<com.amap.api.maps.model.LatLng> originlist = (java.util.List<com.amap.api.maps.model.LatLng>) ((Map<String, Object>) __args__).get("originlist");
|
||||
|
||||
// ref
|
||||
PathSmoothTool __this__ = (PathSmoothTool) ((Map<String, Object>) __args__).get("__this__");
|
||||
|
||||
// print log
|
||||
if (getEnableLog()) {
|
||||
Log.d("fluttify-java", "fluttify-java: com.amap.api.maps.utils.PathSmoothTool@" + __this__ + "::removeNoisePoint(" + originlist + ")");
|
||||
}
|
||||
|
||||
// invoke native method
|
||||
java.util.List<com.amap.api.maps.model.LatLng> __result__ = null;
|
||||
try {
|
||||
__result__ = __this__.removeNoisePoint(originlist);
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
if (getEnableLog()) {
|
||||
Log.d("Current HEAP: ", getHEAP().toString());
|
||||
}
|
||||
__methodResult__.error(throwable.getMessage(), null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
__methodResult__.success(__result__);
|
||||
});
|
||||
// method
|
||||
put("com.amap.api.maps.utils.PathSmoothTool::kalmanFilterPoint__com_amap_api_maps_model_LatLng__com_amap_api_maps_model_LatLng", (__args__, __methodResult__) -> {
|
||||
// args
|
||||
// ref arg
|
||||
com.amap.api.maps.model.LatLng lastLoc = (com.amap.api.maps.model.LatLng) ((Map<String, Object>) __args__).get("lastLoc");
|
||||
// ref arg
|
||||
com.amap.api.maps.model.LatLng curLoc = (com.amap.api.maps.model.LatLng) ((Map<String, Object>) __args__).get("curLoc");
|
||||
|
||||
// ref
|
||||
PathSmoothTool __this__ = (PathSmoothTool) ((Map<String, Object>) __args__).get("__this__");
|
||||
|
||||
// print log
|
||||
if (getEnableLog()) {
|
||||
Log.d("fluttify-java", "fluttify-java: com.amap.api.maps.utils.PathSmoothTool@" + __this__ + "::kalmanFilterPoint(" + lastLoc + curLoc + ")");
|
||||
}
|
||||
|
||||
// invoke native method
|
||||
com.amap.api.maps.model.LatLng __result__ = null;
|
||||
try {
|
||||
__result__ = __this__.kalmanFilterPoint(lastLoc, curLoc);
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
if (getEnableLog()) {
|
||||
Log.d("Current HEAP: ", getHEAP().toString());
|
||||
}
|
||||
__methodResult__.error(throwable.getMessage(), null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
__methodResult__.success(__result__);
|
||||
});
|
||||
// method
|
||||
put("com.amap.api.maps.utils.PathSmoothTool::reducerVerticalThreshold__List_com_amap_api_maps_model_LatLng_", (__args__, __methodResult__) -> {
|
||||
// args
|
||||
// ref arg
|
||||
java.util.List<com.amap.api.maps.model.LatLng> inPoints = (java.util.List<com.amap.api.maps.model.LatLng>) ((Map<String, Object>) __args__).get("inPoints");
|
||||
|
||||
// ref
|
||||
PathSmoothTool __this__ = (PathSmoothTool) ((Map<String, Object>) __args__).get("__this__");
|
||||
|
||||
// print log
|
||||
if (getEnableLog()) {
|
||||
Log.d("fluttify-java", "fluttify-java: com.amap.api.maps.utils.PathSmoothTool@" + __this__ + "::reducerVerticalThreshold(" + inPoints + ")");
|
||||
}
|
||||
|
||||
// invoke native method
|
||||
java.util.List<com.amap.api.maps.model.LatLng> __result__ = null;
|
||||
try {
|
||||
__result__ = __this__.reducerVerticalThreshold(inPoints);
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
if (getEnableLog()) {
|
||||
Log.d("Current HEAP: ", getHEAP().toString());
|
||||
}
|
||||
__methodResult__.error(throwable.getMessage(), null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
__methodResult__.success(__result__);
|
||||
});
|
||||
// method
|
||||
put("com.amap.api.maps.utils.PathSmoothTool::getIntensity", (__args__, __methodResult__) -> {
|
||||
// args
|
||||
|
||||
|
||||
// ref
|
||||
PathSmoothTool __this__ = (PathSmoothTool) ((Map<String, Object>) __args__).get("__this__");
|
||||
|
||||
// print log
|
||||
if (getEnableLog()) {
|
||||
Log.d("fluttify-java", "fluttify-java: com.amap.api.maps.utils.PathSmoothTool@" + __this__ + "::getIntensity(" + "" + ")");
|
||||
}
|
||||
|
||||
// invoke native method
|
||||
Integer __result__ = null;
|
||||
try {
|
||||
__result__ = __this__.getIntensity();
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
if (getEnableLog()) {
|
||||
Log.d("Current HEAP: ", getHEAP().toString());
|
||||
}
|
||||
__methodResult__.error(throwable.getMessage(), null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
__methodResult__.success(__result__);
|
||||
});
|
||||
// factory
|
||||
put("ObjectFactory::createcom_amap_api_maps_utils_PathSmoothTool__", (__args__, __methodResult__) -> {
|
||||
if (getEnableLog()) {
|
||||
Log.d("ObjectFactory", "创建对象: com_amap_api_maps_utils_PathSmoothTool__");
|
||||
}
|
||||
|
||||
// args
|
||||
|
||||
|
||||
// create target object
|
||||
PathSmoothTool __obj__ = new PathSmoothTool();
|
||||
|
||||
// print current HEAP
|
||||
if (getEnableLog()) {
|
||||
Log.d("ObjectFactory", "HEAP: " + getHEAP());
|
||||
}
|
||||
|
||||
__methodResult__.success(__obj__);
|
||||
});
|
||||
// method
|
||||
put("com.amap.api.maps.utils.PathSmoothTool::getIntensity_batch", (__argsBatch__, __methodResult__) -> {
|
||||
List<Integer> __resultList__ = new ArrayList<>();
|
||||
|
||||
for (int __i__ = 0; __i__ < ((List<Map<String, Object>>) __argsBatch__).size(); __i__++) {
|
||||
Map<String, Object> __args__ = ((List<Map<String, Object>>) __argsBatch__).get(__i__);
|
||||
|
||||
// args
|
||||
|
||||
|
||||
// ref
|
||||
PathSmoothTool __this__ = (PathSmoothTool) ((Map<String, Object>) __args__).get("__this__");
|
||||
|
||||
// invoke native method
|
||||
Integer __result__ = null;
|
||||
try {
|
||||
__result__ = __this__.getIntensity();
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
if (getEnableLog()) {
|
||||
Log.d("Current HEAP: ", getHEAP().toString());
|
||||
}
|
||||
__methodResult__.error(throwable.getMessage(), null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
__resultList__.add(__result__);
|
||||
}
|
||||
|
||||
__methodResult__.success(__resultList__);
|
||||
});
|
||||
// method
|
||||
put("com.amap.api.maps.utils.PathSmoothTool::setIntensity_batch", (__argsBatch__, __methodResult__) -> {
|
||||
List<Void> __resultList__ = new ArrayList<>();
|
||||
|
||||
for (int __i__ = 0; __i__ < ((List<Map<String, Object>>) __argsBatch__).size(); __i__++) {
|
||||
Map<String, Object> __args__ = ((List<Map<String, Object>>) __argsBatch__).get(__i__);
|
||||
|
||||
// args
|
||||
// ref arg
|
||||
Number mIntensity = (Number) ((Map<String, Object>) __args__).get("mIntensity");
|
||||
|
||||
// ref
|
||||
PathSmoothTool __this__ = (PathSmoothTool) ((Map<String, Object>) __args__).get("__this__");
|
||||
|
||||
// invoke native method
|
||||
Void __result__ = null;
|
||||
try {
|
||||
__this__.setIntensity(mIntensity.intValue());
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
if (getEnableLog()) {
|
||||
Log.d("Current HEAP: ", getHEAP().toString());
|
||||
}
|
||||
__methodResult__.error(throwable.getMessage(), null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
__resultList__.add(__result__);
|
||||
}
|
||||
|
||||
__methodResult__.success(__resultList__);
|
||||
});
|
||||
// method
|
||||
put("com.amap.api.maps.utils.PathSmoothTool::getThreshhold_batch", (__argsBatch__, __methodResult__) -> {
|
||||
List<Float> __resultList__ = new ArrayList<>();
|
||||
|
||||
for (int __i__ = 0; __i__ < ((List<Map<String, Object>>) __argsBatch__).size(); __i__++) {
|
||||
Map<String, Object> __args__ = ((List<Map<String, Object>>) __argsBatch__).get(__i__);
|
||||
|
||||
// args
|
||||
|
||||
|
||||
// ref
|
||||
PathSmoothTool __this__ = (PathSmoothTool) ((Map<String, Object>) __args__).get("__this__");
|
||||
|
||||
// invoke native method
|
||||
Float __result__ = null;
|
||||
try {
|
||||
__result__ = __this__.getThreshhold();
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
if (getEnableLog()) {
|
||||
Log.d("Current HEAP: ", getHEAP().toString());
|
||||
}
|
||||
__methodResult__.error(throwable.getMessage(), null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
__resultList__.add(__result__);
|
||||
}
|
||||
|
||||
__methodResult__.success(__resultList__);
|
||||
});
|
||||
// method
|
||||
put("com.amap.api.maps.utils.PathSmoothTool::setThreshhold_batch", (__argsBatch__, __methodResult__) -> {
|
||||
List<Void> __resultList__ = new ArrayList<>();
|
||||
|
||||
for (int __i__ = 0; __i__ < ((List<Map<String, Object>>) __argsBatch__).size(); __i__++) {
|
||||
Map<String, Object> __args__ = ((List<Map<String, Object>>) __argsBatch__).get(__i__);
|
||||
|
||||
// args
|
||||
// ref arg
|
||||
Number mThreshhold = (Number) ((Map<String, Object>) __args__).get("mThreshhold");
|
||||
|
||||
// ref
|
||||
PathSmoothTool __this__ = (PathSmoothTool) ((Map<String, Object>) __args__).get("__this__");
|
||||
|
||||
// invoke native method
|
||||
Void __result__ = null;
|
||||
try {
|
||||
__this__.setThreshhold(mThreshhold.floatValue());
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
if (getEnableLog()) {
|
||||
Log.d("Current HEAP: ", getHEAP().toString());
|
||||
}
|
||||
__methodResult__.error(throwable.getMessage(), null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
__resultList__.add(__result__);
|
||||
}
|
||||
|
||||
__methodResult__.success(__resultList__);
|
||||
});
|
||||
// method
|
||||
put("com.amap.api.maps.utils.PathSmoothTool::setNoiseThreshhold_batch", (__argsBatch__, __methodResult__) -> {
|
||||
List<Void> __resultList__ = new ArrayList<>();
|
||||
|
||||
for (int __i__ = 0; __i__ < ((List<Map<String, Object>>) __argsBatch__).size(); __i__++) {
|
||||
Map<String, Object> __args__ = ((List<Map<String, Object>>) __argsBatch__).get(__i__);
|
||||
|
||||
// args
|
||||
// ref arg
|
||||
Number mnoiseThreshhold = (Number) ((Map<String, Object>) __args__).get("mnoiseThreshhold");
|
||||
|
||||
// ref
|
||||
PathSmoothTool __this__ = (PathSmoothTool) ((Map<String, Object>) __args__).get("__this__");
|
||||
|
||||
// invoke native method
|
||||
Void __result__ = null;
|
||||
try {
|
||||
__this__.setNoiseThreshhold(mnoiseThreshhold.floatValue());
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
if (getEnableLog()) {
|
||||
Log.d("Current HEAP: ", getHEAP().toString());
|
||||
}
|
||||
__methodResult__.error(throwable.getMessage(), null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
__resultList__.add(__result__);
|
||||
}
|
||||
|
||||
__methodResult__.success(__resultList__);
|
||||
});
|
||||
// method
|
||||
put("com.amap.api.maps.utils.PathSmoothTool::pathOptimize_batch", (__argsBatch__, __methodResult__) -> {
|
||||
List<java.util.List<com.amap.api.maps.model.LatLng>> __resultList__ = new ArrayList<>();
|
||||
|
||||
for (int __i__ = 0; __i__ < ((List<Map<String, Object>>) __argsBatch__).size(); __i__++) {
|
||||
Map<String, Object> __args__ = ((List<Map<String, Object>>) __argsBatch__).get(__i__);
|
||||
|
||||
// args
|
||||
// ref arg
|
||||
java.util.List<com.amap.api.maps.model.LatLng> originlist = (java.util.List<com.amap.api.maps.model.LatLng>) ((Map<String, Object>) __args__).get("originlist");
|
||||
|
||||
// ref
|
||||
PathSmoothTool __this__ = (PathSmoothTool) ((Map<String, Object>) __args__).get("__this__");
|
||||
|
||||
// invoke native method
|
||||
java.util.List<com.amap.api.maps.model.LatLng> __result__ = null;
|
||||
try {
|
||||
__result__ = __this__.pathOptimize(originlist);
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
if (getEnableLog()) {
|
||||
Log.d("Current HEAP: ", getHEAP().toString());
|
||||
}
|
||||
__methodResult__.error(throwable.getMessage(), null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
__resultList__.add(__result__);
|
||||
}
|
||||
|
||||
__methodResult__.success(__resultList__);
|
||||
});
|
||||
// method
|
||||
put("com.amap.api.maps.utils.PathSmoothTool::kalmanFilterPath__List_com_amap_api_maps_model_LatLng__batch", (__argsBatch__, __methodResult__) -> {
|
||||
List<java.util.List<com.amap.api.maps.model.LatLng>> __resultList__ = new ArrayList<>();
|
||||
|
||||
for (int __i__ = 0; __i__ < ((List<Map<String, Object>>) __argsBatch__).size(); __i__++) {
|
||||
Map<String, Object> __args__ = ((List<Map<String, Object>>) __argsBatch__).get(__i__);
|
||||
|
||||
// args
|
||||
// ref arg
|
||||
java.util.List<com.amap.api.maps.model.LatLng> originlist = (java.util.List<com.amap.api.maps.model.LatLng>) ((Map<String, Object>) __args__).get("originlist");
|
||||
|
||||
// ref
|
||||
PathSmoothTool __this__ = (PathSmoothTool) ((Map<String, Object>) __args__).get("__this__");
|
||||
|
||||
// invoke native method
|
||||
java.util.List<com.amap.api.maps.model.LatLng> __result__ = null;
|
||||
try {
|
||||
__result__ = __this__.kalmanFilterPath(originlist);
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
if (getEnableLog()) {
|
||||
Log.d("Current HEAP: ", getHEAP().toString());
|
||||
}
|
||||
__methodResult__.error(throwable.getMessage(), null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
__resultList__.add(__result__);
|
||||
}
|
||||
|
||||
__methodResult__.success(__resultList__);
|
||||
});
|
||||
// method
|
||||
put("com.amap.api.maps.utils.PathSmoothTool::removeNoisePoint_batch", (__argsBatch__, __methodResult__) -> {
|
||||
List<java.util.List<com.amap.api.maps.model.LatLng>> __resultList__ = new ArrayList<>();
|
||||
|
||||
for (int __i__ = 0; __i__ < ((List<Map<String, Object>>) __argsBatch__).size(); __i__++) {
|
||||
Map<String, Object> __args__ = ((List<Map<String, Object>>) __argsBatch__).get(__i__);
|
||||
|
||||
// args
|
||||
// ref arg
|
||||
java.util.List<com.amap.api.maps.model.LatLng> originlist = (java.util.List<com.amap.api.maps.model.LatLng>) ((Map<String, Object>) __args__).get("originlist");
|
||||
|
||||
// ref
|
||||
PathSmoothTool __this__ = (PathSmoothTool) ((Map<String, Object>) __args__).get("__this__");
|
||||
|
||||
// invoke native method
|
||||
java.util.List<com.amap.api.maps.model.LatLng> __result__ = null;
|
||||
try {
|
||||
__result__ = __this__.removeNoisePoint(originlist);
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
if (getEnableLog()) {
|
||||
Log.d("Current HEAP: ", getHEAP().toString());
|
||||
}
|
||||
__methodResult__.error(throwable.getMessage(), null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
__resultList__.add(__result__);
|
||||
}
|
||||
|
||||
__methodResult__.success(__resultList__);
|
||||
});
|
||||
// method
|
||||
put("com.amap.api.maps.utils.PathSmoothTool::kalmanFilterPoint__com_amap_api_maps_model_LatLng__com_amap_api_maps_model_LatLng_batch", (__argsBatch__, __methodResult__) -> {
|
||||
List<com.amap.api.maps.model.LatLng> __resultList__ = new ArrayList<>();
|
||||
|
||||
for (int __i__ = 0; __i__ < ((List<Map<String, Object>>) __argsBatch__).size(); __i__++) {
|
||||
Map<String, Object> __args__ = ((List<Map<String, Object>>) __argsBatch__).get(__i__);
|
||||
|
||||
// args
|
||||
// ref arg
|
||||
com.amap.api.maps.model.LatLng lastLoc = (com.amap.api.maps.model.LatLng) ((Map<String, Object>) __args__).get("lastLoc");
|
||||
// ref arg
|
||||
com.amap.api.maps.model.LatLng curLoc = (com.amap.api.maps.model.LatLng) ((Map<String, Object>) __args__).get("curLoc");
|
||||
|
||||
// ref
|
||||
PathSmoothTool __this__ = (PathSmoothTool) ((Map<String, Object>) __args__).get("__this__");
|
||||
|
||||
// invoke native method
|
||||
com.amap.api.maps.model.LatLng __result__ = null;
|
||||
try {
|
||||
__result__ = __this__.kalmanFilterPoint(lastLoc, curLoc);
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
if (getEnableLog()) {
|
||||
Log.d("Current HEAP: ", getHEAP().toString());
|
||||
}
|
||||
__methodResult__.error(throwable.getMessage(), null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
__resultList__.add(__result__);
|
||||
}
|
||||
|
||||
__methodResult__.success(__resultList__);
|
||||
});
|
||||
// method
|
||||
put("com.amap.api.maps.utils.PathSmoothTool::reducerVerticalThreshold__List_com_amap_api_maps_model_LatLng__batch", (__argsBatch__, __methodResult__) -> {
|
||||
List<List<LatLng>> __resultList__ = new ArrayList<>();
|
||||
|
||||
for (int __i__ = 0; __i__ < ((List<Map<String, Object>>) __argsBatch__).size(); __i__++) {
|
||||
Map<String, Object> __args__ = ((List<Map<String, Object>>) __argsBatch__).get(__i__);
|
||||
|
||||
// args
|
||||
// ref arg
|
||||
java.util.List<com.amap.api.maps.model.LatLng> inPoints = (java.util.List<com.amap.api.maps.model.LatLng>) ((Map<String, Object>) __args__).get("inPoints");
|
||||
|
||||
// ref
|
||||
PathSmoothTool __this__ = (PathSmoothTool) ((Map<String, Object>) __args__).get("__this__");
|
||||
|
||||
// invoke native method
|
||||
java.util.List<com.amap.api.maps.model.LatLng> __result__ = null;
|
||||
try {
|
||||
__result__ = __this__.reducerVerticalThreshold(inPoints);
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
if (getEnableLog()) {
|
||||
Log.d("Current HEAP: ", getHEAP().toString());
|
||||
}
|
||||
__methodResult__.error(throwable.getMessage(), null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
__resultList__.add(__result__);
|
||||
}
|
||||
|
||||
__methodResult__.success(__resultList__);
|
||||
});
|
||||
//endregion
|
||||
}};
|
||||
}
|
||||
}
|
@ -0,0 +1,301 @@
|
||||
package com.amap.api.maps.utils;
|
||||
|
||||
import com.amap.api.maps.AMapUtils;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 轨迹优化工具类
|
||||
* Created by my94493 on 2017/3/31.
|
||||
* <p>
|
||||
* 使用方法:
|
||||
* <p>
|
||||
* PathSmoothTool pathSmoothTool = new PathSmoothTool();
|
||||
* pathSmoothTool.setIntensity(2);//设置滤波强度,默认3
|
||||
* List<LatLng> mList = LatpathSmoothTool.kalmanFilterPath(list);
|
||||
*/
|
||||
|
||||
public class PathSmoothTool {
|
||||
private int mIntensity = 3;
|
||||
private float mThreshhold = 0.3f;
|
||||
private float mNoiseThreshhold = 10;
|
||||
|
||||
public PathSmoothTool(){
|
||||
|
||||
}
|
||||
|
||||
public int getIntensity() {
|
||||
return mIntensity;
|
||||
}
|
||||
|
||||
public void setIntensity(int mIntensity) {
|
||||
this.mIntensity = mIntensity;
|
||||
}
|
||||
|
||||
public float getThreshhold() {
|
||||
return mThreshhold;
|
||||
}
|
||||
|
||||
public void setThreshhold(float mThreshhold) {
|
||||
this.mThreshhold = mThreshhold;
|
||||
}
|
||||
|
||||
public void setNoiseThreshhold(float mnoiseThreshhold) {
|
||||
this.mNoiseThreshhold = mnoiseThreshhold;
|
||||
}
|
||||
|
||||
/**
|
||||
* 轨迹平滑优化
|
||||
* @param originlist 原始轨迹list,list.size大于2
|
||||
* @return 优化后轨迹list
|
||||
*/
|
||||
public List<LatLng> pathOptimize(List<LatLng> originlist){
|
||||
|
||||
List<LatLng> list = removeNoisePoint(originlist);//去噪
|
||||
List<LatLng> afterList = kalmanFilterPath(list,mIntensity);//滤波
|
||||
List<LatLng> pathoptimizeList = reducerVerticalThreshold(afterList,mThreshhold);//抽稀
|
||||
// Log.i("MY","originlist: "+originlist.size());
|
||||
// Log.i("MY","list: "+list.size());
|
||||
// Log.i("MY","afterList: "+afterList.size());
|
||||
// Log.i("MY","pathoptimizeList: "+pathoptimizeList.size());
|
||||
return pathoptimizeList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 轨迹线路滤波
|
||||
* @param originlist 原始轨迹list,list.size大于2
|
||||
* @return 滤波处理后的轨迹list
|
||||
*/
|
||||
public List<LatLng> kalmanFilterPath(List<LatLng> originlist) {
|
||||
return kalmanFilterPath(originlist,mIntensity);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 轨迹去噪,删除垂距大于20m的点
|
||||
* @param originlist 原始轨迹list,list.size大于2
|
||||
* @return
|
||||
*/
|
||||
public List<LatLng> removeNoisePoint(List<LatLng> originlist){
|
||||
return reduceNoisePoint(originlist,mNoiseThreshhold);
|
||||
}
|
||||
|
||||
/**
|
||||
* 单点滤波
|
||||
* @param lastLoc 上次定位点坐标
|
||||
* @param curLoc 本次定位点坐标
|
||||
* @return 滤波后本次定位点坐标值
|
||||
*/
|
||||
public LatLng kalmanFilterPoint(LatLng lastLoc, LatLng curLoc) {
|
||||
return kalmanFilterPoint(lastLoc,curLoc,mIntensity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 轨迹抽稀
|
||||
* @param inPoints 待抽稀的轨迹list,至少包含两个点,删除垂距小于mThreshhold的点
|
||||
* @return 抽稀后的轨迹list
|
||||
*/
|
||||
public List<LatLng> reducerVerticalThreshold(List<LatLng> inPoints) {
|
||||
return reducerVerticalThreshold(inPoints,mThreshhold);
|
||||
}
|
||||
|
||||
/********************************************************************************************************/
|
||||
/**
|
||||
* 轨迹线路滤波
|
||||
* @param originlist 原始轨迹list,list.size大于2
|
||||
* @param intensity 滤波强度(1—5)
|
||||
* @return
|
||||
*/
|
||||
private List<LatLng> kalmanFilterPath(List<LatLng> originlist,int intensity) {
|
||||
List<LatLng> kalmanFilterList = new ArrayList<LatLng>();
|
||||
if (originlist == null || originlist.size() <= 2)
|
||||
return kalmanFilterList;
|
||||
initial();//初始化滤波参数
|
||||
LatLng latLng = null;
|
||||
LatLng lastLoc = originlist.get(0);
|
||||
kalmanFilterList.add(lastLoc);
|
||||
for (int i = 1; i < originlist.size(); i++) {
|
||||
LatLng curLoc = originlist.get(i);
|
||||
latLng = kalmanFilterPoint(lastLoc,curLoc,intensity);
|
||||
if (latLng != null) {
|
||||
kalmanFilterList.add(latLng);
|
||||
lastLoc = latLng;
|
||||
}
|
||||
}
|
||||
return kalmanFilterList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 单点滤波
|
||||
* @param lastLoc 上次定位点坐标
|
||||
* @param curLoc 本次定位点坐标
|
||||
* @param intensity 滤波强度(1—5)
|
||||
* @return 滤波后本次定位点坐标值
|
||||
*/
|
||||
private LatLng kalmanFilterPoint(LatLng lastLoc, LatLng curLoc, int intensity) {
|
||||
if (pdelt_x == 0 || pdelt_y == 0 ){
|
||||
initial();
|
||||
}
|
||||
LatLng kalmanLatlng = null;
|
||||
if (lastLoc == null || curLoc == null){
|
||||
return kalmanLatlng;
|
||||
}
|
||||
if (intensity < 1){
|
||||
intensity = 1;
|
||||
} else if (intensity > 5){
|
||||
intensity = 5;
|
||||
}
|
||||
for (int j = 0; j < intensity; j++){
|
||||
kalmanLatlng = kalmanFilter(lastLoc.longitude,curLoc.longitude,lastLoc.latitude,curLoc.latitude);
|
||||
curLoc = kalmanLatlng;
|
||||
}
|
||||
return kalmanLatlng;
|
||||
}
|
||||
|
||||
|
||||
/***************************卡尔曼滤波开始********************************/
|
||||
private double lastLocation_x; //上次位置
|
||||
private double currentLocation_x;//这次位置
|
||||
private double lastLocation_y; //上次位置
|
||||
private double currentLocation_y;//这次位置
|
||||
private double estimate_x; //修正后数据
|
||||
private double estimate_y; //修正后数据
|
||||
private double pdelt_x; //自预估偏差
|
||||
private double pdelt_y; //自预估偏差
|
||||
private double mdelt_x; //上次模型偏差
|
||||
private double mdelt_y; //上次模型偏差
|
||||
private double gauss_x; //高斯噪音偏差
|
||||
private double gauss_y; //高斯噪音偏差
|
||||
private double kalmanGain_x; //卡尔曼增益
|
||||
private double kalmanGain_y; //卡尔曼增益
|
||||
|
||||
private double m_R= 0;
|
||||
private double m_Q= 0;
|
||||
//初始模型
|
||||
private void initial(){
|
||||
pdelt_x = 0.001;
|
||||
pdelt_y = 0.001;
|
||||
// mdelt_x = 0;
|
||||
// mdelt_y = 0;
|
||||
mdelt_x = 5.698402909980532E-4;
|
||||
mdelt_y = 5.698402909980532E-4;
|
||||
}
|
||||
private LatLng kalmanFilter(double oldValue_x, double value_x, double oldValue_y, double value_y){
|
||||
lastLocation_x = oldValue_x;
|
||||
currentLocation_x= value_x;
|
||||
gauss_x = Math.sqrt(pdelt_x * pdelt_x + mdelt_x * mdelt_x)+m_Q; //计算高斯噪音偏差
|
||||
kalmanGain_x = Math.sqrt((gauss_x * gauss_x)/(gauss_x * gauss_x + pdelt_x * pdelt_x)) +m_R; //计算卡尔曼增益
|
||||
estimate_x = kalmanGain_x * (currentLocation_x - lastLocation_x) + lastLocation_x; //修正定位点
|
||||
mdelt_x = Math.sqrt((1-kalmanGain_x) * gauss_x *gauss_x); //修正模型偏差
|
||||
|
||||
lastLocation_y = oldValue_y;
|
||||
currentLocation_y = value_y;
|
||||
gauss_y = Math.sqrt(pdelt_y * pdelt_y + mdelt_y * mdelt_y)+m_Q; //计算高斯噪音偏差
|
||||
kalmanGain_y = Math.sqrt((gauss_y * gauss_y)/(gauss_y * gauss_y + pdelt_y * pdelt_y)) +m_R; //计算卡尔曼增益
|
||||
estimate_y = kalmanGain_y * (currentLocation_y - lastLocation_y) + lastLocation_y; //修正定位点
|
||||
mdelt_y = Math.sqrt((1-kalmanGain_y) * gauss_y * gauss_y); //修正模型偏差
|
||||
|
||||
LatLng latlng = new LatLng(estimate_y,estimate_x);
|
||||
|
||||
|
||||
return latlng;
|
||||
}
|
||||
/***************************卡尔曼滤波结束**********************************/
|
||||
|
||||
/***************************抽稀算法*************************************/
|
||||
private List<LatLng> reducerVerticalThreshold(List<LatLng> inPoints,
|
||||
float threshHold) {
|
||||
if (inPoints == null) {
|
||||
return null;
|
||||
}
|
||||
if (inPoints.size() <= 2) {
|
||||
return inPoints;
|
||||
}
|
||||
List<LatLng> ret = new ArrayList<LatLng>();
|
||||
for (int i = 0; i < inPoints.size(); i++) {
|
||||
LatLng pre = getLastLocation(ret);
|
||||
LatLng cur = inPoints.get(i);
|
||||
if (pre == null || i == inPoints.size() - 1) {
|
||||
ret.add(cur);
|
||||
continue;
|
||||
}
|
||||
LatLng next = inPoints.get(i + 1);
|
||||
double distance = calculateDistanceFromPoint(cur, pre, next);
|
||||
if (distance > threshHold){
|
||||
ret.add(cur);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
private static LatLng getLastLocation(List<LatLng> oneGraspList) {
|
||||
if (oneGraspList == null || oneGraspList.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
int locListSize = oneGraspList.size();
|
||||
LatLng lastLocation = oneGraspList.get(locListSize - 1);
|
||||
return lastLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算当前点到线的垂线距离
|
||||
* @param p 当前点
|
||||
* @param lineBegin 线的起点
|
||||
* @param lineEnd 线的终点
|
||||
*
|
||||
*/
|
||||
private static double calculateDistanceFromPoint(LatLng p, LatLng lineBegin,
|
||||
LatLng lineEnd) {
|
||||
double A = p.longitude - lineBegin.longitude;
|
||||
double B = p.latitude - lineBegin.latitude;
|
||||
double C = lineEnd.longitude - lineBegin.longitude;
|
||||
double D = lineEnd.latitude - lineBegin.latitude;
|
||||
|
||||
double dot = A * C + B * D;
|
||||
double len_sq = C * C + D * D;
|
||||
double param = dot / len_sq;
|
||||
|
||||
double xx, yy;
|
||||
|
||||
if (param < 0 || (lineBegin.longitude == lineEnd.longitude
|
||||
&& lineBegin.latitude == lineEnd.latitude)) {
|
||||
xx = lineBegin.longitude;
|
||||
yy = lineBegin.latitude;
|
||||
// return -1;
|
||||
} else if (param > 1) {
|
||||
xx = lineEnd.longitude;
|
||||
yy = lineEnd.latitude;
|
||||
// return -1;
|
||||
} else {
|
||||
xx = lineBegin.longitude + param * C;
|
||||
yy = lineBegin.latitude + param * D;
|
||||
}
|
||||
return AMapUtils.calculateLineDistance(p,new LatLng(yy,xx));
|
||||
}
|
||||
/***************************抽稀算法结束*********************************/
|
||||
|
||||
private List<LatLng> reduceNoisePoint(List<LatLng> inPoints, float threshHold) {
|
||||
if (inPoints == null) {
|
||||
return null;
|
||||
}
|
||||
if (inPoints.size() <= 2) {
|
||||
return inPoints;
|
||||
}
|
||||
List<LatLng> ret = new ArrayList<LatLng>();
|
||||
for (int i = 0; i < inPoints.size(); i++) {
|
||||
LatLng pre = getLastLocation(ret);
|
||||
LatLng cur = inPoints.get(i);
|
||||
if (pre == null || i == inPoints.size() - 1) {
|
||||
ret.add(cur);
|
||||
continue;
|
||||
}
|
||||
LatLng next = inPoints.get(i + 1);
|
||||
double distance = calculateDistanceFromPoint(cur, pre, next);
|
||||
if (distance < threshHold){
|
||||
ret.add(cur);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package me.yohom.amap_map_fluttify.sub_handler.custom.tile_provider;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.amap.api.maps.model.UrlTileProvider;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
public class UrlTileProviderImpl extends UrlTileProvider {
|
||||
|
||||
public UrlTileProviderImpl(int width, int height, String urlTemplate) {
|
||||
super(width, height);
|
||||
this.urlTemplate = urlTemplate;
|
||||
}
|
||||
|
||||
final String urlTemplate;
|
||||
|
||||
@Override
|
||||
public URL getTileUrl(int x, int y, int zoom) {
|
||||
try {
|
||||
final String url = urlTemplate
|
||||
.replace("{x}", String.valueOf(x))
|
||||
.replace("{y}", String.valueOf(y))
|
||||
.replace("{scale}", String.valueOf(zoom));
|
||||
Log.d("瓦片地址", url);
|
||||
return new URL(url);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user