From 40294e429a3df2203130f4a7b70abb656021211f Mon Sep 17 00:00:00 2001 From: shisaiqun Date: Fri, 21 Oct 2022 15:44:08 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../survey/data/DataRepositories.java | 87 ++++--------------- .../cn/org/landcloud/survey/util/Utils.java | 40 ++++++++- build.gradle | 18 +++- gradle/wrapper/gradle-wrapper.properties | 6 +- ssl/build.gradle | 7 -- 5 files changed, 74 insertions(+), 84 deletions(-) diff --git a/app/src/main/java/cn/org/landcloud/survey/data/DataRepositories.java b/app/src/main/java/cn/org/landcloud/survey/data/DataRepositories.java index 72e4ff6..17d129b 100644 --- a/app/src/main/java/cn/org/landcloud/survey/data/DataRepositories.java +++ b/app/src/main/java/cn/org/landcloud/survey/data/DataRepositories.java @@ -3,40 +3,30 @@ package cn.org.landcloud.survey.data; import static cn.org.landcloud.survey.util.Constants.CERT_ORG_CODE; import static cn.org.landcloud.survey.util.Constants.TEST_CER; import static cn.org.landcloud.survey.util.Constants.TEST_CERT_ORG_PUBLICKEY; -import static cn.org.landcloud.survey.util.Constants.TEST_PUBLICKEY; import android.content.Context; import android.os.Environment; -import android.util.Base64; import androidx.annotation.NonNull; -import androidx.exifinterface.media.ExifInterface; import org.json.JSONObject; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.math.BigDecimal; -import java.nio.charset.StandardCharsets; -import java.text.NumberFormat; import java.util.HashMap; -import cn.org.landcloud.security.Util; -import cn.org.landcloud.security.sm2.SM2SignVO; -import cn.org.landcloud.security.sm2.SM2SignVerUtils; import cn.org.landcloud.security.sm3.SM3Utils; -import cn.org.landcloud.survey.util.Constants; -import cn.org.landcloud.survey.util.FileIOUtils; -import cn.org.landcloud.survey.util.TimeUtils; -import cn.org.landcloud.survey.util.Utils; import cn.org.landcloud.survey.data.bean.DBInfo; import cn.org.landcloud.survey.data.bean.DCHSXX; import cn.org.landcloud.survey.data.bean.FJ; import cn.org.landcloud.survey.data.bean.JMXX; import cn.org.landcloud.survey.data.bean.KZXXYSJ; import cn.org.landcloud.survey.data.bean.TBJBXX; +import cn.org.landcloud.survey.util.Constants; +import cn.org.landcloud.survey.util.FileIOUtils; +import cn.org.landcloud.survey.util.TimeUtils; +import cn.org.landcloud.survey.util.Utils; public class DataRepositories { @@ -181,15 +171,9 @@ public class DataRepositories { fj_phone_normal.setPSTZ("J"); File file = new File(Environment.getExternalStorageDirectory(),RELATIVE_FJ_DIR+"phone_1.jpg"); - ExifInterface exifInterface; fj_phone_normal.setFJ(FileIOUtils.readFile2BytesByChannel(file)); try { fj_phone_normal.setFJHXZ(SM3Utils.sm3(file)); - exifInterface = new ExifInterface(file); - exifInterface.setAttribute(ExifInterface.TAG_ARTIST, Base64Encode("test")); - exifInterface.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, decimalToDMS(119.9854736)); - exifInterface.setAttribute(ExifInterface.TAG_GPS_LATITUDE, decimalToDMS(30.2776146)); - exifInterface.saveAttributes(); } catch (IOException e) { e.printStackTrace(); } @@ -220,9 +204,9 @@ public class DataRepositories { content.append(fj_phone_normal.getPSSJ()).append(","); content.append(Utils.doubleFormat(fj_phone_normal.getLongitude())).append(","); content.append(Utils.doubleFormat(fj_phone_normal.getLatitude())).append(","); - content.append(Utils.doubleFormat(fj_phone_normal.getPSFYJ())).append(","); - content.append(Utils.doubleFormat(fj_phone_normal.getPSJD())).append(","); - content.append(Utils.doubleFormat(fj_phone_normal.getPSHGJ())).append(","); + content.append(fj_phone_normal.getPSFYJ()).append(","); + content.append(fj_phone_normal.getPSJD()).append(","); + content.append(fj_phone_normal.getPSHGJ()).append(","); content.append(fj_phone_normal.getPSRY()).append(","); content.append(fj_phone_normal.getZSDM()); String jym = Utils.makeJYM(content.toString(),Constants.TEST_PRIVATEKEY); @@ -248,11 +232,6 @@ public class DataRepositories { fj_phone_panoramic.setFJ(FileIOUtils.readFile2BytesByChannel(file)); try { fj_phone_panoramic.setFJHXZ(SM3Utils.sm3(file)); - exifInterface = new ExifInterface(file); - exifInterface.setAttribute(ExifInterface.TAG_ARTIST, Base64Encode("test")); - exifInterface.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, decimalToDMS(119.9854813)); - exifInterface.setAttribute(ExifInterface.TAG_GPS_LATITUDE, decimalToDMS(30.2775860)); - exifInterface.saveAttributes(); } catch (IOException e) { e.printStackTrace(); } @@ -282,9 +261,9 @@ public class DataRepositories { content.append(fj_phone_panoramic.getPSSJ()).append(","); content.append(Utils.doubleFormat(fj_phone_panoramic.getLongitude())).append(","); content.append(Utils.doubleFormat(fj_phone_panoramic.getLatitude())).append(","); - content.append(Utils.doubleFormat(fj_phone_panoramic.getPSFYJ())).append(","); - content.append(Utils.doubleFormat(fj_phone_panoramic.getPSJD())).append(","); - content.append(Utils.doubleFormat(fj_phone_panoramic.getPSHGJ())).append(","); + content.append(fj_phone_panoramic.getPSFYJ()).append(","); + content.append(fj_phone_panoramic.getPSJD()).append(","); + content.append(fj_phone_panoramic.getPSHGJ()).append(","); content.append(fj_phone_panoramic.getPSRY()).append(","); content.append(fj_phone_panoramic.getZSDM()); fj_phone_panoramic.setJYM(Utils.makeJYM(content.toString(),Constants.TEST_PRIVATEKEY)); @@ -303,11 +282,6 @@ public class DataRepositories { fj_uav_normal.setFJ(FileIOUtils.readFile2BytesByChannel(file)); try { fj_uav_normal.setFJHXZ(SM3Utils.sm3(file)); - exifInterface = new ExifInterface(file); - exifInterface.setAttribute(ExifInterface.TAG_ARTIST, Base64Encode("kmap")); - exifInterface.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, decimalToDMS(119.9855061)); - exifInterface.setAttribute(ExifInterface.TAG_GPS_LATITUDE, decimalToDMS(30.2774821)); - exifInterface.saveAttributes(); } catch (IOException e) { e.printStackTrace(); } @@ -337,9 +311,9 @@ public class DataRepositories { content.append(fj_uav_normal.getPSSJ()).append(","); content.append(Utils.doubleFormat(fj_uav_normal.getLongitude())).append(","); content.append(Utils.doubleFormat(fj_uav_normal.getLatitude())).append(","); - content.append(Utils.doubleFormat(fj_uav_normal.getPSFYJ())).append(","); - content.append(Utils.doubleFormat(fj_uav_normal.getPSJD())).append(","); - content.append(Utils.doubleFormat(fj_uav_normal.getPSHGJ())).append(","); + content.append(fj_uav_normal.getPSFYJ()).append(","); + content.append(fj_uav_normal.getPSJD()).append(","); + content.append(fj_uav_normal.getPSHGJ()).append(","); content.append(fj_uav_normal.getPSRY()).append(","); content.append(fj_uav_normal.getZSDM()); fj_uav_normal.setJYM(Utils.makeJYM(content.toString(),Constants.TEST_PRIVATEKEY)); @@ -359,11 +333,6 @@ public class DataRepositories { fj_uav_panoramic.setFJ(FileIOUtils.readFile2BytesByChannel(file)); try { fj_uav_panoramic.setFJHXZ(SM3Utils.sm3(file)); - exifInterface = new ExifInterface(file); - exifInterface.setAttribute(ExifInterface.TAG_ARTIST, Base64Encode("kmap")); - exifInterface.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, decimalToDMS(119.9855061)); - exifInterface.setAttribute(ExifInterface.TAG_GPS_LATITUDE, decimalToDMS(30.2774821)); - exifInterface.saveAttributes(); } catch (IOException e) { e.printStackTrace(); } @@ -393,9 +362,9 @@ public class DataRepositories { content.append(fj_uav_panoramic.getPSSJ()).append(","); content.append(Utils.doubleFormat(fj_uav_panoramic.getLongitude())).append(","); content.append(Utils.doubleFormat(fj_uav_panoramic.getLatitude())).append(","); - content.append(Utils.doubleFormat(fj_uav_panoramic.getPSFYJ())).append(","); - content.append(Utils.doubleFormat(fj_uav_panoramic.getPSJD())).append(","); - content.append(Utils.doubleFormat(fj_uav_panoramic.getPSHGJ())).append(","); + content.append(fj_uav_panoramic.getPSFYJ()).append(","); + content.append(fj_uav_panoramic.getPSJD()).append(","); + content.append(fj_uav_panoramic.getPSHGJ()).append(","); content.append(fj_uav_panoramic.getPSRY()).append(","); content.append(fj_uav_panoramic.getZSDM()); fj_uav_panoramic.setJYM(Utils.makeJYM(content.toString(),Constants.TEST_PRIVATEKEY)); @@ -442,9 +411,9 @@ public class DataRepositories { content.append(fj_video.getPSSJ()).append(","); content.append(Utils.doubleFormat(fj_video.getLongitude())).append(","); content.append(Utils.doubleFormat(fj_video.getLatitude())).append(","); - content.append(Utils.doubleFormat(fj_video.getPSFYJ())).append(","); - content.append(Utils.doubleFormat(fj_video.getPSJD())).append(","); - content.append(Utils.doubleFormat(fj_video.getPSHGJ())).append(","); + content.append(fj_video.getPSFYJ()).append(","); + content.append(fj_video.getPSJD()).append(","); + content.append(fj_video.getPSHGJ()).append(","); content.append(fj_video.getPSRY()).append(","); content.append(fj_video.getZSDM()); fj_video.setJYM(Utils.makeJYM(content.toString(),Constants.TEST_PRIVATEKEY)); @@ -500,22 +469,4 @@ public class DataRepositories { } } - private String Base64Encode(String s) { - return Base64.encodeToString(s.getBytes(), Base64.DEFAULT); - } - - /** - * 经纬度 转 度分秒 - * - * @param value - latitude or longitude - * @return - */ - private String decimalToDMS(double value) { - int num1 = (int) Math.floor(value); - int num2 = (int) Math.floor((value - num1) * 60); - double num3 = (value - ((double) num1 + ((double) num2 / 60))) * 360000000; - return num1 + "/1," + num2 + "/1," + num3 + "/100000"; - } - - } diff --git a/app/src/main/java/cn/org/landcloud/survey/util/Utils.java b/app/src/main/java/cn/org/landcloud/survey/util/Utils.java index de44dbd..14512ef 100644 --- a/app/src/main/java/cn/org/landcloud/survey/util/Utils.java +++ b/app/src/main/java/cn/org/landcloud/survey/util/Utils.java @@ -1,12 +1,15 @@ package cn.org.landcloud.survey.util; +import androidx.exifinterface.media.ExifInterface; + +import java.io.File; +import java.io.IOException; import java.nio.charset.StandardCharsets; import java.text.DecimalFormat; -import java.text.NumberFormat; +import java.util.HashMap; +import java.util.Map; import cn.org.landcloud.security.Util; -import cn.org.landcloud.security.sm2.SM2; -import cn.org.landcloud.security.sm2.SM2EncDecUtils; import cn.org.landcloud.security.sm2.SM2SignVO; import cn.org.landcloud.security.sm2.SM2SignVerUtils; import cn.org.landcloud.security.sm3.SM3Utils; @@ -35,4 +38,35 @@ public class Utils { DecimalFormat df = new DecimalFormat("##########.#########"); return df.format(value); } + + /** + * 经纬度 转 度分秒 + * + * @param value - latitude or longitude + * @return + */ + public static String decimalToDMS(double value) { + int num1 = (int) Math.floor(value); + int num2 = (int) Math.floor((value - num1) * 60); + double num3 = (value - ((double) num1 + ((double) num2 / 60))) * 360000000; + return num1 + "/1," + num2 + "/1," + num3 + "/100000"; + } + + /** + * 照片属性写入类 + * @param file + * @param attributes + */ + public static void writeExifAttributes(File file, HashMap attributes) { + ExifInterface exifInterface; + try { + exifInterface = new ExifInterface(file); + for(Map.Entry entry:attributes.entrySet()) { + exifInterface.setAttribute(entry.getKey(), entry.getValue()); + } + exifInterface.saveAttributes(); + } catch (IOException e) { + e.printStackTrace(); + } + } } diff --git a/build.gradle b/build.gradle index 90f9008..7cbb664 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,17 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. -plugins { - id 'com.android.application' version '7.3.0' apply false - id 'com.android.library' version '7.3.0' apply false +buildscript { + repositories { + google() + mavenCentral() + } + dependencies { + classpath "com.android.tools.build:gradle:7.0.3" + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +task clean(type: Delete) { + delete rootProject.buildDir } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ca4f6da..10d6367 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Oct 12 10:45:05 CST 2022 +#Fri Oct 21 08:48:54 CST 2022 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME +zipStoreBase=GRADLE_USER_HOME \ No newline at end of file diff --git a/ssl/build.gradle b/ssl/build.gradle index 0b2e45b..e99a484 100644 --- a/ssl/build.gradle +++ b/ssl/build.gradle @@ -6,13 +6,6 @@ java { sourceCompatibility = JavaVersion.VERSION_1_7 targetCompatibility = JavaVersion.VERSION_1_7 -/* task makeJar(type: jar) { - delete 'ssl.jar' - from file('src/main/java/') - destinationDir = file('build/libs') - archiveName = 'ssl.jar' - } - makeJar.dependsOn(build)*/ } dependencies {