Просмотр исходного кода

APIModuleGis 增加获取测地通广播坐标方式 1.2.3

1037015548@qq.com 1 год назад
Родитель
Сommit
daf490063e

BIN
.gradle/5.6.4/executionHistory/executionHistory.bin


BIN
.gradle/5.6.4/executionHistory/executionHistory.lock


BIN
.gradle/5.6.4/fileHashes/fileHashes.bin


BIN
.gradle/5.6.4/fileHashes/fileHashes.lock


BIN
.gradle/5.6.4/fileHashes/resourceHashesCache.bin


BIN
.gradle/5.6.4/javaCompile/classAnalysis.bin


BIN
.gradle/5.6.4/javaCompile/jarAnalysis.bin


BIN
.gradle/5.6.4/javaCompile/javaCompile.lock


BIN
.gradle/buildOutputCleanup/buildOutputCleanup.lock


BIN
app/build/intermediates/dex/debug/mergeLibDexDebug/out/classes_0.dex


+ 1 - 1
app/build/intermediates/incremental/packageDebug/tmp/debug/dex-renamer-state.txt

@@ -1,4 +1,4 @@
-#Tue Dec 26 14:15:08 CST 2023
+#Wed Dec 27 18:20:07 CST 2023
 path.1=classes.dex
 path.0=classes.dex
 renamed.7=classes8.dex

+ 21 - 0
app/src/main/assets/widget/index_frm.html

@@ -87,6 +87,24 @@
 	        alert("获取结果为基本数据!\n结果:" + JSON.stringify(res));
 		}
 
+		function startCeditongIntent(){
+			var param = {};
+	        var res = uzmoduleGis.startCeditongIntent(param);
+	        alert("获取结果为基本数据!\n结果:" + JSON.stringify(res));
+		}
+		function getIntentGis(){
+			var param = {};
+	        var res = uzmoduleGis.getIntentGis(param);
+	        alert("获取结果为基本数据!\n结果:" + JSON.stringify(res));
+		}
+		function stopCeditongIntent(){
+			var param = {};
+	        var res = uzmoduleGis.stopCeditongIntent(param);
+	        alert("获取结果为基本数据!\n结果:" + JSON.stringify(res));
+		}
+
+
+
 		function BMshowAlert(){
 			var param = {msg:"Hello APICloud!"};
 			api.require('ModuleB').showAlert(param);
@@ -224,6 +242,9 @@
 				<div class="clickbtn" tapmode="active" onclick="gisLatLng()" >获取经纬度</div>
 				<div class="clickbtn" tapmode="active" onclick="gisLatLng2()" >获取经纬度2</div>
 				<div class="clickbtn" tapmode="active" onclick="stopGisService()" >停止GisService</div>
+				<div class="clickbtn" tapmode="active" onclick="startCeditongIntent()" >注册测地通广播</div>
+				<div class="clickbtn" tapmode="active" onclick="getIntentGis()" >获取广播经纬度</div>
+				<div class="clickbtn" tapmode="active" onclick="stopCeditongIntent()" >释放测地通广播</div>
 			<div class='itemtitle'>2、启动Activity</div>
 				<div class="clickbtn" tapmode="active" onclick="startActivity()" >startActivity</div>
 				<div class="clickbtn" tapmode="active" onclick="startActivityForResult()" >startActivityForResult</div>

+ 68 - 1
moduleGis/src/main/java/com/example/moduleGis/APIModuleGis.java

@@ -8,6 +8,7 @@ import android.content.Context;
 import android.content.DialogInterface;
 import android.content.DialogInterface.OnClickListener;
 import android.content.Intent;
+import android.content.IntentFilter;
 import android.content.pm.PackageManager;
 import android.net.Uri;
 import android.os.Build;
@@ -29,6 +30,7 @@ import android.widget.Toast;
 import com.example.moduleGis.gnsstest.DiffConnectManager;
 import com.example.moduleGis.gnsstest.GnssListener;
 import com.example.moduleGis.gnsstest.GnssServiceManager;
+import com.example.moduleGis.gnsstest.ReceiveLocationBroadcastReceiver;
 import com.example.moduleGis.gnsstest.ReceiverConnectProxy;
 import com.example.moduleGis.gnsstest.consts.BleStatusDefine;
 import com.example.moduleGis.gnsstest.event.GnssConnectStatusEvent;
@@ -58,8 +60,10 @@ import org.json.JSONObject;
 
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
+import java.util.Map;
 import java.util.TimeZone;
 import java.util.Timer;
 import java.util.TimerTask;
@@ -116,6 +120,69 @@ public class APIModuleGis extends UZModule {
 		gnssInfoJson = "";
 	}
 
+	ReceiveLocationBroadcastReceiver myReceiver;
+
+	//TODO Lx 启动广播接收
+	public ModuleResult jsmethod_startCeditongIntent_sync(final UZModuleContext context){
+		JSONObject res = new JSONObject();
+		try {
+			if (myReceiver!=null){
+				this.context().unregisterReceiver(myReceiver);
+			}
+			myReceiver=new ReceiveLocationBroadcastReceiver();
+			IntentFilter intentFilter=new IntentFilter();
+			intentFilter.addAction("com.huace.landstar.api.action");
+			this.context().registerReceiver(myReceiver,intentFilter);
+			res.put("code", "0");
+			res.put("msg", "");
+		}catch(Exception ex){
+			Log.e(TAG,ex.getLocalizedMessage());
+		}
+		return new ModuleResult(res);
+	}
+
+	//TODO 获取广播经纬度
+	public ModuleResult jsmethod_getIntentGis_sync(final UZModuleContext context){
+		JSONObject res = new JSONObject();
+		try {
+			res.put("code", "1");
+			res.put("msg", "");
+			res.put("version", "1.2.3");
+
+			//TODO 逻辑块
+			Map<String,Object> dataMap = new HashMap<>();
+			dataMap.put("wgslng",ReceiveLocationBroadcastReceiver.wgslng);
+			dataMap.put("wgslat",ReceiveLocationBroadcastReceiver.wgslat);
+			dataMap.put("wgsblh",ReceiveLocationBroadcastReceiver.wgsblh);
+			dataMap.put("solveStatus",ReceiveLocationBroadcastReceiver.solveStatus);
+			dataMap.put("conenctItent",ReceiveLocationBroadcastReceiver.conenctItent);
+
+			ReceiveLocationBroadcastReceiver.wgslng = "";
+			ReceiveLocationBroadcastReceiver.wgslat = "";
+			ReceiveLocationBroadcastReceiver.wgsblh = "";
+			ReceiveLocationBroadcastReceiver.solveStatus = "";
+			ReceiveLocationBroadcastReceiver.conenctItent = "1";
+			res.put("code","0");
+			res.put("data", com.qx.wz.external.fastjson.JSONObject.toJSONString(dataMap));
+		}catch(Exception ex){
+			Log.e(TAG,ex.getLocalizedMessage());
+		}
+		return new ModuleResult(res);
+	}
+
+	//TODO LX 释放广播接收器
+	public ModuleResult jsmethod_stopCeditongIntent_sync(final UZModuleContext context){
+		JSONObject res = new JSONObject();
+		try {
+			res.put("code", "0");
+			res.put("msg", "");
+			this.context().unregisterReceiver(myReceiver);
+		}catch(Exception ex){
+			Log.e(TAG,ex.getLocalizedMessage());
+		}
+		return new ModuleResult(res);
+	}
+
 	//TODO Lx 统一断开所有的服务
 	public ModuleResult jsmethod_stopAllService_sync(final UZModuleContext context){
 		JSONObject res = new JSONObject();
@@ -313,7 +380,7 @@ public class APIModuleGis extends UZModule {
 						userName!=null&&userName.length()>0&&
 						passWord!=null&&passWord.length()>0){
 					//TODO 重连必须满足以上条件
-					if(!"0".equals(logCorsCod)&&!"1".equals(logCorsStatus)) {
+					if("0".equals(connectCode)&&!"0".equals(logCorsCod)&&!"1".equals(logCorsStatus)) {
 						DiffConnectManager.loginCors(this.context(), ip, port, mountName, userName, passWord, diffType, stationId, type);
 					}
 				}

+ 59 - 0
moduleGis/src/main/java/com/example/moduleGis/gnsstest/ReceiveLocationBroadcastReceiver.java

@@ -0,0 +1,59 @@
+package com.example.moduleGis.gnsstest;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.location.Location;
+import android.util.Log;
+
+/**
+ * 功能: 监听测地通广播信息
+ * 作者: LX
+ * 日期:2023年12月27日
+ */
+public class ReceiveLocationBroadcastReceiver extends BroadcastReceiver {
+    public static final String LOCATION_INFO_INTENT = "com.huace.landstar.api.action";
+    public static final String KEY_LOCATION_FIFO = "location";
+    private final StringBuffer mStringBuffer;
+
+    public volatile static String wgslng = "";
+    public volatile static String wgslat = "";
+    public volatile static String wgsblh = "";
+    public volatile static String solveStatus = "";
+
+    public volatile static String conenctItent = "1";//0 已接收广播 1 未接收广播
+    public ReceiveLocationBroadcastReceiver() {
+        mStringBuffer = new StringBuffer();
+    }
+    @Override
+    public void onReceive(Context context, Intent intent) {
+        if (intent != null && intent.getAction().equals(LOCATION_INFO_INTENT)) {
+            Location location = intent.getParcelableExtra(KEY_LOCATION_FIFO);
+            if (location != null) {
+                mStringBuffer.delete(0, mStringBuffer.length());
+                mStringBuffer.append("Location[").append("<br>");
+                mStringBuffer.append("Provider = 				  	").append(location.getProvider()).append(",").append("<br>");
+                double latitude = Math.toDegrees(location.getLatitude());
+                mStringBuffer.append("B = ").append(latitude).append(",").append("<br>");
+                double longitude = Math.toDegrees(location.getLongitude());
+                mStringBuffer.append("L = ").append(longitude).append(",").append("<br>");
+                mStringBuffer.append("H = 	").append(location.getAltitude()).append(",").append("<br>");
+                mStringBuffer.append("HPre = 	").append(location.getAccuracy()).append(",").append("<br>");
+                //板卡解算状态-1:搜星中 0:单点  1:SBAS 2:浮动 3:固定 4: 伪距差分
+                mStringBuffer.append("solve_status= 	").append(location.getExtras().get("solve_status")).append(",").append("<br>");
+                mStringBuffer.append("x_precision= 	").append(location.getExtras().get("x_precision")).append(",").append("<br>");
+                mStringBuffer.append("y_precision= 	").append(location.getExtras().get("y_precision")).append(",").append("<br>");
+                mStringBuffer.append("h_precision= 	").append(location.getExtras().get("h_precision")).append(",").append("<br>");
+                mStringBuffer.append("key_neh_n= 	").append(location.getExtras().get("key_neh_n")).append(",").append("<br>");
+                mStringBuffer.append("key_neh_e= 	").append(location.getExtras().get("key_neh_e")).append(",").append("<br>");
+                mStringBuffer.append("key_neh_h= 	").append(location.getExtras().get("key_neh_h")).append(",").append("<br>");
+                Log.d("TAG","LocationInfo: "+mStringBuffer.toString());
+                wgslng = String.valueOf(longitude);
+                wgslat = String.valueOf(latitude);
+                wgsblh = String.valueOf(location.getAltitude());
+                solveStatus = String.valueOf(location.getExtras().get("solve_status"));
+                conenctItent = "0";
+            }
+        }
+    }
+}