代码样例代码样例代码样例

目录

1、依赖

2、bean

2.1、CaptureImage

2.2、CaptureImageDamage

2.3、ImageDamageVo

2.4、ImageFromServer

2.5、LatLngList

2.6、RddImage

2.7、Result

2.8、ResultCode

3、utils

3.1、BitmapUtils

3.2、DisplayUtil

3.3、DistanceUtil

3.4、LaunchTimer

3.5、LogUtils

3.6、TimeUtils

4、sql

4.1、SqliteConstant

4.2、MySqliteHelper

4.3、DbManager


1、依赖

implementation "com.amap.api:3dmap:latest.integration"
implementation "com.amap.api:location:latest.integration"

2、bean

2.1、CaptureImage

/**
 * on 2020/2/25
 * Description: 跟 RddImage 相似的实体类,用于 接口 ${RequestCenter postRddImageList }
 */

public class CaptureImage {

    private String imageId;
//    private byte[] image;
    private String image;
    private double angle;
    private double width;
    private double height;
    private double dpiWidth;
    private double dpiHeight;
    private String geoMapInfo;
    private double longitude;
    private double latitude;
    private String street;
    private String address;
    private double altitude;
    private String captureTime;

//    public byte[] getImage() {
//        return image;
//    }
//
//    public void setImage(byte[] image) {
//        this.image = image;
//    }


    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public String getImageId() {
        return imageId;
    }

    public void setImageId(String imageId) {
        this.imageId = imageId;
    }


    public double getAngle() {
        return angle;
    }

    public void setAngle(double angle) {
        this.angle = angle;
    }

    public double getWidth() {
        return width;
    }

    public void setWidth(double width) {
        this.width = width;
    }

    public double getHeight() {
        return height;
    }

    public void setHeight(double height) {
        this.height = height;
    }

    public double getDpiWidth() {
        return dpiWidth;
    }

    public void setDpiWidth(double dpiWidth) {
        this.dpiWidth = dpiWidth;
    }

    public double getDpiHeight() {
        return dpiHeight;
    }

    public void setDpiHeight(double dpiHeight) {
        this.dpiHeight = dpiHeight;
    }

    public String getGeoMapInfo() {
        return geoMapInfo;
    }

    public void setGeoMapInfo(String geoMapInfo) {
        this.geoMapInfo = geoMapInfo;
    }

    public double getLongitude() {
        return longitude;
    }

    public void setLongitude(double longitude) {
        this.longitude = longitude;
    }

    public double getLatitude() {
        return latitude;
    }

    public void setLatitude(double latitude) {
        this.latitude = latitude;
    }

    public String getStreet() {
        return street;
    }

    public void setStreet(String street) {
        this.street = street;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public double getAltitude() {
        return altitude;
    }

    public void setAltitude(double altitude) {
        this.altitude = altitude;
    }

    public String getCaptureTime() {
        return captureTime;
    }

    public void setCaptureTime(String captureTime) {
        this.captureTime = captureTime;
    }
}
public class MainActivity extends AppCompatActivity {

   

    private MySqliteHelper helper;
    private SQLiteDatabase db;
    // 用来存放 LatLng 的 list,然后将其显示在地图上
    List<LatLng> mLatLngList = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        // 地址为: 广东省深圳市宝安区裕安二路31号靠近中国建设银行(深圳前进支行),经度为:113.903287,维度为:22.575178
        helper = DbManager.getInstance(this);
        db = helper.getWritableDatabase();
        mLatLngList = DbManager.queryLonLatInCertainArea(db, mLongitude, mLatitude);

    }
}

 

2.2、CaptureImageDamage

/**
 * on 2020/3/3
 * Description: 用于 接口 ${RequestCenter postRddImageDamageList }
 */

public class CaptureImageDamage {

    private String damageId;
    private String imageId;
    private String damageCode;
    private double confident;
    private double damageLeft;
    private double damageTop;
    private double damageRight;
    private double damageBottom;

    @Override
    public String toString() {
        return "CaptureImageDamage{" +
                "damageId='" + damageId + '\'' +
                ", imageId='" + imageId + '\'' +
                ", damageCode='" + damageCode + '\'' +
                '}';
    }

    public String getDamageId() {
        return damageId;
    }

    public void setDamageId(String damageId) {
        this.damageId = damageId;
    }

    public String getImageId() {
        return imageId;
    }

    public void setImageId(String imageId) {
        this.imageId = imageId;
    }

    public String getDamageCode() {
        return damageCode;
    }

    public void setDamageCode(String damageCode) {
        this.damageCode = damageCode;
    }

    public double getConfident() {
        return confident;
    }

    public void setConfident(double confident) {
        this.confident = confident;
    }

    public double getDamageLeft() {
        return damageLeft;
    }

    public void setDamageLeft(double damageLeft) {
        this.damageLeft = damageLeft;
    }

    public double getDamageTop() {
        return damageTop;
    }

    public void setDamageTop(double damageTop) {
        this.damageTop = damageTop;
    }

    public double getDamageRight() {
        return damageRight;
    }

    public void setDamageRight(double damageRight) {
        this.damageRight = damageRight;
    }

    public double getDamageBottom() {
        return damageBottom;
    }

    public void setDamageBottom(double damageBottom) {
        this.damageBottom = damageBottom;
    }
}

2.3、ImageDamageVo

/**
 * 综合查询 rdd_images 表和 rdd_image_damages表 而 得出 实体类
 */
public class ImageDamageVo implements Serializable {

    private String damageId;
    private String imageId;
    // 图片
    private byte[] imageData;
    private double angle;
    private long creationDate;
    private String street;
    private String address;
    private String damageCode;
    private float confident;
    private float damageLeft;
    private float damageTop;
    private float damageRight;
    private float damageBottom;

    @Override
    public String toString() {
        return "ImageDamageVo{" +
//                "damageId='" + damageId + '\'' +
//                "imageId='" + imageId + '\'' +
//                ", imageData=" + Arrays.toString(imageData) +
//                ", angle=" + angle +
//                ", creationTime='" + creationTime + '\'' +
//                ", street='" + street + '\'' +
//                ", address='" + address + '\'' +
//                ", damageCode='" + damageCode + '\'' +
                ", confident=" + confident +
//                ", damageLeft=" + damageLeft +
//                ", damageTop=" + damageTop +
//                ", damageRight=" + damageRight +
//                ", damageBottom=" + damageBottom +
                '}';
    }

    public ImageDamageVo() {
    }


    public String getDamageId() {
        return damageId;
    }

    public void setDamageId(String damageId) {
        this.damageId = damageId;
    }

    public float getDamageLeft() {
        return damageLeft;
    }

    public void setDamageLeft(float damageLeft) {
        this.damageLeft = damageLeft;
    }

    public float getDamageTop() {
        return damageTop;
    }

    public void setDamageTop(float damageTop) {
        this.damageTop = damageTop;
    }

    public float getDamageRight() {
        return damageRight;
    }

    public void setDamageRight(float damageRight) {
        this.damageRight = damageRight;
    }

    public float getDamageBottom() {
        return damageBottom;
    }

    public void setDamageBottom(float damageBottom) {
        this.damageBottom = damageBottom;
    }

    public String getImageId() {
        return imageId;
    }

    public void setImageId(String imageId) {
        this.imageId = imageId;
    }

    public byte[] getImageData() {
        return imageData;
    }

    public void setImageData(byte[] imageData) {
        this.imageData = imageData;
    }

    public double getAngle() {
        return angle;
    }

    public void setAngle(double angle) {
        this.angle = angle;
    }

    public long getCreationDate() {
        return creationDate;
    }

    public void setCreationDate(long creationDate) {
        this.creationDate = creationDate;
    }

    public String getStreet() {
        return street;
    }

    public void setStreet(String street) {
        this.street = street;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getDamageCode() {
        return damageCode;
    }

    public void setDamageCode(String damageCode) {
        this.damageCode = damageCode;
    }

    public float getConfident() {
        return confident;
    }

    public void setConfident(float confident) {
        this.confident = confident;
    }

}

2.4、ImageFromServer

/**
 * on 2020/3/13
 * Description:
 */

public class ImageFromServer {


    /**
     * content : [{"creationDate":"2020-03-10T16:00:00.000+0000","lastUpdatedDate":null,"createdBy":null,"lastUpdatedBy":null,"imageId":"abccf94a-8b27-4553-8f37-7320d0427456","image":"O","angle":90,"width":640,"height":480,"dpiWidth":1440,"dpiHeight":2408,"geoMapInfo":"gd_map","longitude":113.95426,"latitude":22.531901,"street":"沙河西路","address":"沙河西路1837号深圳湾科技生态园2区","altitude":0,"captureTime":"1583477465785","imageDamages":[{"creationDate":"2020-03-17T03:16:46.758+0000","lastUpdatedDate":null,"createdBy":null,"lastUpdatedBy":null,"damageId":"691e7e44-ff47-46c7-8a43-e8bf44f6b5cd","imageId":"6772a331-fcf1-45de-8cc8-970433c89aa6","damageCode":"标线模糊","confident":0.9622076749801636,"damageLeft":362.13604736328125,"damageTop":23.831451416015625,"damageRight":492.87353515625,"damageBottom":424.9625549316406}]},{"creationDate":"2020-03-10T16:00:00.000+0000","lastUpdatedDate":null,"createdBy":null,"lastUpdatedBy":null,"imageId":"5654a9a2-8198-41cb-a361-b5129caf66e3","image":"IJy","angle":90,"width":640,"height":480,"dpiWidth":1440,"dpiHeight":2408,"geoMapInfo":"gd_map","longitude":113.95426,"latitude":22.531901,"street":"沙河西路","address":"沙河西路1837号深圳湾科技生态园2区","altitude":0,"captureTime":"1583477468800","imageDamages":[]}]
     * pageable : {"sort":{"sorted":false,"unsorted":true,"empty":true},"offset":10,"pageSize":10,"pageNumber":1,"unpaged":false,"paged":true}
     * totalPages : 2
     * totalElements : 16
     * last : true
     * number : 1
     * size : 10
     * sort : {"sorted":false,"unsorted":true,"empty":true}
     * numberOfElements : 6
     * first : false
     * empty : false
     */

    private PageableBean pageable;
    private int totalPages;
    private int totalElements;
    private boolean last;
    private int number;
    private int size;
    private SortBeanX sort;
    private int numberOfElements;
    private boolean first;
    private boolean empty;
    private List<ContentBean> content;

    public PageableBean getPageable() {
        return pageable;
    }

    public void setPageable(PageableBean pageable) {
        this.pageable = pageable;
    }

    public int getTotalPages() {
        return totalPages;
    }

    public void setTotalPages(int totalPages) {
        this.totalPages = totalPages;
    }

    public int getTotalElements() {
        return totalElements;
    }

    public void setTotalElements(int totalElements) {
        this.totalElements = totalElements;
    }

    public boolean isLast() {
        return last;
    }

    public void setLast(boolean last) {
        this.last = last;
    }

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public SortBeanX getSort() {
        return sort;
    }

    public void setSort(SortBeanX sort) {
        this.sort = sort;
    }

    public int getNumberOfElements() {
        return numberOfElements;
    }

    public void setNumberOfElements(int numberOfElements) {
        this.numberOfElements = numberOfElements;
    }

    public boolean isFirst() {
        return first;
    }

    public void setFirst(boolean first) {
        this.first = first;
    }

    public boolean isEmpty() {
        return empty;
    }

    public void setEmpty(boolean empty) {
        this.empty = empty;
    }

    public List<ContentBean> getContent() {
        return content;
    }

    public void setContent(List<ContentBean> content) {
        this.content = content;
    }

    public static class ContentBean {
        /**
         * creationDate : 2020-03-10T16:00:00.000+0000
         * lastUpdatedDate : null
         * createdBy : null
         * lastUpdatedBy : null
         * imageId : abccf94a-8b27-4553-8f37-7320d0427456
         * image : O
         * angle : 90
         * width : 640
         * height : 480
         * dpiWidth : 1440
         * dpiHeight : 2408
         * geoMapInfo : gd_map
         * longitude : 113.95426
         * latitude : 22.531901
         * street : 沙河西路
         * address : 沙河西路1837号深圳湾科技生态园2区
         * altitude : 0
         * captureTime : 1583477465785
         * imageDamages : [{"creationDate":"2020-03-17T03:16:46.758+0000","lastUpdatedDate":null,"createdBy":null,"lastUpdatedBy":null,"damageId":"691e7e44-ff47-46c7-8a43-e8bf44f6b5cd","imageId":"6772a331-fcf1-45de-8cc8-970433c89aa6","damageCode":"标线模糊","confident":0.9622076749801636,"damageLeft":362.13604736328125,"damageTop":23.831451416015625,"damageRight":492.87353515625,"damageBottom":424.9625549316406}]
         */

        private String creationDate;
        private Object lastUpdatedDate;
        private Object createdBy;
        private Object lastUpdatedBy;
        private String imageId;
        private String image;
        private int angle;
        private int width;
        private int height;
        private int dpiWidth;
        private int dpiHeight;
        private String geoMapInfo;
        private double longitude;
        private double latitude;
        private String street;
        private String address;
        private int altitude;
        private String captureTime;
        private List<ImageDamagesBean> imageDamages;

        public String getCreationDate() {
            return creationDate;
        }

        public void setCreationDate(String creationDate) {
            this.creationDate = creationDate;
        }

        public Object getLastUpdatedDate() {
            return lastUpdatedDate;
        }

        public void setLastUpdatedDate(Object lastUpdatedDate) {
            this.lastUpdatedDate = lastUpdatedDate;
        }

        public Object getCreatedBy() {
            return createdBy;
        }

        public void setCreatedBy(Object createdBy) {
            this.createdBy = createdBy;
        }

        public Object getLastUpdatedBy() {
            return lastUpdatedBy;
        }

        public void setLastUpdatedBy(Object lastUpdatedBy) {
            this.lastUpdatedBy = lastUpdatedBy;
        }

        public String getImageId() {
            return imageId;
        }

        public void setImageId(String imageId) {
            this.imageId = imageId;
        }

        public String getImage() {
            return image;
        }

        public void setImage(String image) {
            this.image = image;
        }

        public int getAngle() {
            return angle;
        }

        public void setAngle(int angle) {
            this.angle = angle;
        }

        public int getWidth() {
            return width;
        }

        public void setWidth(int width) {
            this.width = width;
        }

        public int getHeight() {
            return height;
        }

        public void setHeight(int height) {
            this.height = height;
        }

        public int getDpiWidth() {
            return dpiWidth;
        }

        public void setDpiWidth(int dpiWidth) {
            this.dpiWidth = dpiWidth;
        }

        public int getDpiHeight() {
            return dpiHeight;
        }

        public void setDpiHeight(int dpiHeight) {
            this.dpiHeight = dpiHeight;
        }

        public String getGeoMapInfo() {
            return geoMapInfo;
        }

        public void setGeoMapInfo(String geoMapInfo) {
            this.geoMapInfo = geoMapInfo;
        }

        public double getLongitude() {
            return longitude;
        }

        public void setLongitude(double longitude) {
            this.longitude = longitude;
        }

        public double getLatitude() {
            return latitude;
        }

        public void setLatitude(double latitude) {
            this.latitude = latitude;
        }

        public String getStreet() {
            return street;
        }

        public void setStreet(String street) {
            this.street = street;
        }

        public String getAddress() {
            return address;
        }

        public void setAddress(String address) {
            this.address = address;
        }

        public int getAltitude() {
            return altitude;
        }

        public void setAltitude(int altitude) {
            this.altitude = altitude;
        }

        public String getCaptureTime() {
            return captureTime;
        }

        public void setCaptureTime(String captureTime) {
            this.captureTime = captureTime;
        }

        public List<ImageDamagesBean> getImageDamages() {
            return imageDamages;
        }

        public void setImageDamages(List<ImageDamagesBean> imageDamages) {
            this.imageDamages = imageDamages;
        }

        public static class ImageDamagesBean {
            /**
             * creationDate : 2020-03-17T03:16:46.758+0000
             * lastUpdatedDate : null
             * createdBy : null
             * lastUpdatedBy : null
             * damageId : 691e7e44-ff47-46c7-8a43-e8bf44f6b5cd
             * imageId : 6772a331-fcf1-45de-8cc8-970433c89aa6
             * damageCode : 标线模糊
             * confident : 0.9622076749801636
             * damageLeft : 362.13604736328125
             * damageTop : 23.831451416015625
             * damageRight : 492.87353515625
             * damageBottom : 424.9625549316406
             */

            private String creationDate;
            private Object lastUpdatedDate;
            private Object createdBy;
            private Object lastUpdatedBy;
            private String damageId;
            private String imageId;
            private String damageCode;
            private double confident;
            private double damageLeft;
            private double damageTop;
            private double damageRight;
            private double damageBottom;

            public String getCreationDate() {
                return creationDate;
            }

            public void setCreationDate(String creationDate) {
                this.creationDate = creationDate;
            }

            public Object getLastUpdatedDate() {
                return lastUpdatedDate;
            }

            public void setLastUpdatedDate(Object lastUpdatedDate) {
                this.lastUpdatedDate = lastUpdatedDate;
            }

            public Object getCreatedBy() {
                return createdBy;
            }

            public void setCreatedBy(Object createdBy) {
                this.createdBy = createdBy;
            }

            public Object getLastUpdatedBy() {
                return lastUpdatedBy;
            }

            public void setLastUpdatedBy(Object lastUpdatedBy) {
                this.lastUpdatedBy = lastUpdatedBy;
            }

            public String getDamageId() {
                return damageId;
            }

            public void setDamageId(String damageId) {
                this.damageId = damageId;
            }

            public String getImageId() {
                return imageId;
            }

            public void setImageId(String imageId) {
                this.imageId = imageId;
            }

            public String getDamageCode() {
                return damageCode;
            }

            public void setDamageCode(String damageCode) {
                this.damageCode = damageCode;
            }

            public double getConfident() {
                return confident;
            }

            public void setConfident(double confident) {
                this.confident = confident;
            }

            public double getDamageLeft() {
                return damageLeft;
            }

            public void setDamageLeft(double damageLeft) {
                this.damageLeft = damageLeft;
            }

            public double getDamageTop() {
                return damageTop;
            }

            public void setDamageTop(double damageTop) {
                this.damageTop = damageTop;
            }

            public double getDamageRight() {
                return damageRight;
            }

            public void setDamageRight(double damageRight) {
                this.damageRight = damageRight;
            }

            public double getDamageBottom() {
                return damageBottom;
            }

            public void setDamageBottom(double damageBottom) {
                this.damageBottom = damageBottom;
            }
        }
    }

    public static class PageableBean {
        /**
         * sort : {"sorted":false,"unsorted":true,"empty":true}
         * offset : 10
         * pageSize : 10
         * pageNumber : 1
         * unpaged : false
         * paged : true
         */

        private SortBean sort;
        private int offset;
        private int pageSize;
        private int pageNumber;
        private boolean unpaged;
        private boolean paged;

        public SortBean getSort() {
            return sort;
        }

        public void setSort(SortBean sort) {
            this.sort = sort;
        }

        public int getOffset() {
            return offset;
        }

        public void setOffset(int offset) {
            this.offset = offset;
        }

        public int getPageSize() {
            return pageSize;
        }

        public void setPageSize(int pageSize) {
            this.pageSize = pageSize;
        }

        public int getPageNumber() {
            return pageNumber;
        }

        public void setPageNumber(int pageNumber) {
            this.pageNumber = pageNumber;
        }

        public boolean isUnpaged() {
            return unpaged;
        }

        public void setUnpaged(boolean unpaged) {
            this.unpaged = unpaged;
        }

        public boolean isPaged() {
            return paged;
        }

        public void setPaged(boolean paged) {
            this.paged = paged;
        }

        public static class SortBean {
            /**
             * sorted : false
             * unsorted : true
             * empty : true
             */

            private boolean sorted;
            private boolean unsorted;
            private boolean empty;

            public boolean isSorted() {
                return sorted;
            }

            public void setSorted(boolean sorted) {
                this.sorted = sorted;
            }

            public boolean isUnsorted() {
                return unsorted;
            }

            public void setUnsorted(boolean unsorted) {
                this.unsorted = unsorted;
            }

            public boolean isEmpty() {
                return empty;
            }

            public void setEmpty(boolean empty) {
                this.empty = empty;
            }
        }
    }

    public static class SortBeanX {
        /**
         * sorted : false
         * unsorted : true
         * empty : true
         */

        private boolean sorted;
        private boolean unsorted;
        private boolean empty;

        public boolean isSorted() {
            return sorted;
        }

        public void setSorted(boolean sorted) {
            this.sorted = sorted;
        }

        public boolean isUnsorted() {
            return unsorted;
        }

        public void setUnsorted(boolean unsorted) {
            this.unsorted = unsorted;
        }

        public boolean isEmpty() {
            return empty;
        }

        public void setEmpty(boolean empty) {
            this.empty = empty;
        }
    }



}

2.5、LatLngList


/**
 * on 2020/3/9
 * Description:
 */

public class LatLngList {

    /**
     * [{
         "latitude": 22.532004,
         "longitude": 113.954318
         }, {
         "latitude": 22.532004,
         "longitude": 113.954318
       }]

     */

    private List<LatLngView> latLngViews;

    public List<LatLngView> getLatLngViews() {
        return latLngViews;
    }

    public void setLatLngViews(List<LatLngView> latLngViews) {
        this.latLngViews = latLngViews;
    }

    @Override
    public String toString() {
        return "LatLngList{" +
                "latLngViews=" + latLngViews.toString() +
                '}';
    }

    public static class LatLngView {

        private double latitude;
        private double longitude;

        public double getLatitude() {
            return latitude;
        }

        public void setLatitude(double latitude) {
            this.latitude = latitude;
        }

        public double getLongitude() {
            return longitude;
        }

        public void setLongitude(double longitude) {
            this.longitude = longitude;
        }

        @Override
        public String toString() {
            return "LatLngView{" +
                    "latitude=" + latitude +
                    ", longitude=" + longitude +
                    '}';
        }
    }


}

2.6、RddImage


/**
 *  on 2019/11/27.
 * RddImages 实体类
 */

public class RddImage {

    private String imageId;

    private byte[] imageData;

    // 将imageData转为base64,以方便给服务器上传
    private String imageDataBase64;

    private double angle;
    private double width;
    private double height;
    private double dpiWidth;
    private double dpiHeight;
    private String geoMapInfo;
    private double longitude;
    private double latitude;
    private String street;
    private String address;
    private double altitude;
    //图片采集时间;数据类型:int;必须有数据
    private long captureTime;

    //图片标记,用以标记是否上传到服务器;数据类型:int(0为false,1为true);  必须有数据
    private int isUploaded;

    private int createdBy;
    private String creationDate;
    private int lastUpdatedBy;
    private String lastUpdatedDate;

    /**
     * 部分参数构造函数,该构造函数用于上传到服务器使用
     */
    public RddImage(String imageId, String imageDataBase64, double angle, double width, double height,
                    double dpiWidth, double dpiHeight, String geoMapInfo, double longitude,
                    double latitude,  String street, String address,double altitude, long captureTime) {
        this.imageId = imageId;
        this.imageDataBase64 = imageDataBase64;
        this.angle = angle;
        this.width = width;
        this.height = height;
        this.dpiWidth = dpiWidth;
        this.dpiHeight = dpiHeight;
        this.geoMapInfo = geoMapInfo;
        this.longitude = longitude;
        this.latitude = latitude;
        this.altitude = altitude;
        this.street = street;
        this.address = address;
        this.captureTime = captureTime;
    }

    /**
     * 部分参数构造函数,该构造函数用于上传到服务器使用
     */
    public RddImage(String imageId, byte[] imageData, double angle, double width, double height,
                    double dpiWidth, double dpiHeight, String geoMapInfo, double longitude,
                    double latitude,  String street, String address,double altitude, long captureTime) {
        this.imageId = imageId;
        this.imageData = imageData;
        this.angle = angle;
        this.width = width;
        this.height = height;
        this.dpiWidth = dpiWidth;
        this.dpiHeight = dpiHeight;
        this.geoMapInfo = geoMapInfo;
        this.longitude = longitude;
        this.latitude = latitude;
        this.altitude = altitude;
        this.street = street;
        this.address = address;
        this.captureTime = captureTime;
    }

    /**
     * 全部参数构造函数
     */
    public RddImage(String imageId, byte[] imageData, double angle, double width, double height,
                    double dpiWidth, double dpiHeight, String geoMapInfo, double longitude,
                    double latitude, String street, String address, double altitude,
                    long captureTime, int isUploaded, int createdBy, String creationDate,
                    int lastUpdatedBy, String lastUpdatedDate) {
        this.imageId = imageId;
        this.imageData = imageData;
        this.angle = angle;
        this.width = width;
        this.height = height;
        this.dpiWidth = dpiWidth;
        this.dpiHeight = dpiHeight;
        this.geoMapInfo = geoMapInfo;
        this.longitude = longitude;
        this.latitude = latitude;
        this.street = street;
        this.address = address;
        this.altitude = altitude;
        this.captureTime = captureTime;
        this.isUploaded = isUploaded;
        this.createdBy = createdBy;
        this.creationDate = creationDate;
        this.lastUpdatedBy = lastUpdatedBy;
        this.lastUpdatedDate = lastUpdatedDate;
    }

    @Override
    public String toString() {
        return "RddImage{" +
                "imageId='" + imageId + '\'' +
                ", longitude=" + longitude +
                ", latitude=" + latitude +
                ", captureTime=" + captureTime +
                '}';
    }

    public int getIsUploaded() {
        return isUploaded;
    }

    public void setIsUploaded(int isUploaded) {
        this.isUploaded = isUploaded;
    }

    public long getCaptureTime() {
        return captureTime;
    }

    public void setCaptureTime(long captureTime) {
        this.captureTime = captureTime;
    }

    public String getCreationDate() {
        return creationDate;
    }

    public void setCreationDate(String creationDate) {
        this.creationDate = creationDate;
    }

    public String getLastUpdatedDate() {
        return lastUpdatedDate;
    }

    public void setLastUpdatedDate(String lastUpdatedDate) {
        this.lastUpdatedDate = lastUpdatedDate;
    }

    public String getStreet() {
        return street;
    }

    public void setStreet(String street) {
        this.street = street;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getImageId() {
        return imageId;
    }

    public void setImageId(String imageId) {
        this.imageId = imageId;
    }

    public byte[] getImageData() {
        return imageData;
    }

    public void setImageData(byte[] imageData) {
        this.imageData = imageData;
    }

    public double getAngle() {
        return angle;
    }

    public void setAngle(double angle) {
        this.angle = angle;
    }

    public double getWidth() {
        return width;
    }

    public void setWidth(double width) {
        this.width = width;
    }

    public double getHeight() {
        return height;
    }

    public void setHeight(double height) {
        this.height = height;
    }

    public double getDpiWidth() {
        return dpiWidth;
    }

    public void setDpiWidth(double dpiWidth) {
        this.dpiWidth = dpiWidth;
    }

    public double getDpiHeight() {
        return dpiHeight;
    }

    public void setDpiHeight(double dpiHeight) {
        this.dpiHeight = dpiHeight;
    }

    public String getGeoMapInfo() {
        return geoMapInfo;
    }

    public void setGeoMapInfo(String geoMapInfo) {
        this.geoMapInfo = geoMapInfo;
    }

    public double getLongitude() {
        return longitude;
    }

    public void setLongitude(double longitude) {
        this.longitude = longitude;
    }

    public double getLatitude() {
        return latitude;
    }

    public void setLatitude(double latitude) {
        this.latitude = latitude;
    }

    public double getAltitude() {
        return altitude;
    }

    public void setAltitude(double altitude) {
        this.altitude = altitude;
    }

    public int getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(int createdBy) {
        this.createdBy = createdBy;
    }


    public int getLastUpdatedBy() {
        return lastUpdatedBy;
    }

    public void setLastUpdatedBy(int lastUpdatedBy) {
        this.lastUpdatedBy = lastUpdatedBy;
    }

}

2.7、Result


/**
 * on 2020/3/6
 * Description:
 */

public class Result {

    /**
     * code : 0
     * data : {}
     * msg : string
     */

    private int code;
    private DataBean data;
    private String msg;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public DataBean getData() {
        return data;
    }

    public void setData(DataBean data) {
        this.data = data;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public static class DataBean {
    }
}

2.8、ResultCode


/**
 * on 2020/3/9
 * Description:
 */

public interface ResultCode {
    /**
     * 200 请求成功
     * -1 请求失败
     *
     * 10000 网络繁忙
     *
     * 10002 添加成功
     * 10003 添加失败
     *
     * 100021 添加图片列表成功
     * 100031 添加图片列表失败
     *
     * 100022 添加图片病害列表成功
     * 100032 添加图片病害列表失败
     *
     * 100023 添加单个图片病害成功
     * 100033 添加单个图片病害失败
     *
     * 10004 删除成功
     * 10005 删除失败
     *
     * 100041 删除病害成功
     * 100051 删除病害失败
     *
     * 100042 删除图片成功
     * 100052 删除图片失败
     *
     * 10006 更新成功
     * 10007 更新失败
     *
     * 10008 该值存在
     * 10009 某个值不存在
     *
     *
     */

    // 请求成功
    int REQUEST_SUCCESS = 200;
    String STR_REQUEST_SUCCESS = "请求成功";

    // 请求失败
    int REQUEST_FAIL = -1;
    String STR_REQUEST_FAIL = "请求失败";

    // 网络繁忙
    int NET_ERROR = 10000;
    String STR_NET_ERROR = "网络繁忙";

    // 添加成功
    int ADD_SUCCESS = 10002;
    String STR_ADD_SUCCESS = "添加成功";

    // 添加失败
    int ADD_FAIL = 10003;
    String STR_ADD_FAIL = "添加失败";

    // 添加图片列表成功
    int ADD_IMAGES_SUCCESS = 100021;
    String STR_ADD_IMAGES_SUCCESS = "添加图片列表成功";

    // 添加图片列表失败
    int ADD_IMAGES_FAIL = 100031;
    String STR_ADD_IMAGES_FAIL = "添加图片列表失败";

    // 添加图片病害列表成功
    int ADD_IMAGE_DAMAGESS_SUCCESS = 100022;
    String STR_ADD_IMAGE_DAMAGESS_SUCCESS = "添加图片病害列表成功";

    // 添加图片病害列表失败
    int ADD_IMAGE_DAMAGESS_FAIL = 100032;
    String STR_ADD_IMAGE_DAMAGESS_FAIL = "添加图片病害列表失败";

    // 添加图片病害列表成功
    int ADD_IMAGE_DAMAGE_SUCCESS = 100023;
    String STR_ADD_IMAGE_DAMAGE_SUCCESS = "添加一个图片病害成功";

    // 添加图片病害列表失败
    int ADD_IMAGE_DAMAGE_FAIL = 100033;
    String STR_ADD_IMAGE_DAMAGE_FAIL = "添加一个图片病害列表失败";

    // 删除成功
    int DELETE_SUCCESS = 10004;
    String STR_DELETE_SUCCESS = "删除成功";

    // 删除失败
    int DELETE_FAIL = 10005;
    String STR_DELETE_FAIL = "删除失败";

    // 删除病害成功
    int DELETE_DAMAGE_SUCCESS = 100041;
    String STR_DELETE_DAMAGE_SUCCESS = "删除病害成功";

    // 删除病害失败
    int DELETE_DAMAGE_FAIL = 100051;
    String STR_DELETE_DAMAGE_FAIL = "删除病害失败";

    // 删除图片成功
    int DELETE_IMAGE_SUCCESS = 100042;
    String STR_DELETE_IMAGE_SUCCESS = "删除图片成功";

    // 删除图片失败
    int DELETE_IMAGE_FAIL = 100052;
    String STR_DELETE_IMAGE_FAIL = "删除图片失败";

    // 更新成功
    int UPDATE_SUCCESS = 10006;
    String STR_UPDATE_SUCCESS = "更新成功";

    // 更新失败
    int UPDATE_FAIL = 10007;
    String STR_UPDATE_FAIL = "更新失败";

    // 该值存在
    int EXIST = 10008;
    String STR_EXIST = "该值存在";

    // 某个值不存在
    int NOT_EXIST = 10009;
    String STR_NO_EXIST = "该值不存在";


}

3、utils

3.1、BitmapUtils


/**
 * on 2019/11/27.
 * Bitmap 工具类
 */

public class BitmapUtils {

    /**
     * 画一个圆
     *
     * @param radius 圆的弧度
     * @param color  颜色
     * @return
     */
    public static Bitmap drawCircle(int radius, int color) {

        Bitmap bitmap = Bitmap.createBitmap(radius * 2, radius * 2,
                Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        Paint paint = new Paint();
        RectF rectF = new RectF(0, 0, radius * 2, radius * 2);
        paint.setColor(color);
        canvas.drawArc(rectF, 0, 360, true, paint);
        return bitmap;
    }

    /**
     * 图片转为二进制数据
     *
     * @return byte数组
     */
    public static byte[] bitmapToBytes(Bitmap bitmap) {

//        BitmapFactory.Options options = new BitmapFactory.Options();
        缩小为原来的4*4倍,原来的16个像素点变为1个像素点
//        options.inSampleSize = 4;
        将图片转化为位图
//        Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher, options);
//
//        int a = getBitmapSize(bitmap);
//        LogUtils.e("a: " + a);

        int size = bitmap.getWidth() * bitmap.getHeight() * 4;
        //创建一个字节数组输出流,流的大小为size
        ByteArrayOutputStream baos = new ByteArrayOutputStream(size);
        try {
            //设置位图的压缩格式,质量为100%,并放入字节数组输出流中
            bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
            //将字节数组输出流转化为字节数组byte[]
            //将数组打印出来
//            LogUtils.e(Arrays.toString(baos.toByteArray()));
            return baos.toByteArray();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
//                bitmap.recycle();
                baos.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return new byte[0];
    }

    /**
     * 二进制流 转换为 base64格式
     *
     * @param bytes bytes
     * @return
     */
    @TargetApi(Build.VERSION_CODES.O)
    public static String byteArrayToBase64(byte[] bytes) {
        Base64.Encoder encoder = Base64.getEncoder();
        return encoder.encodeToString(bytes);
    }

    /**
     * base64格式 转换为 二进制流 格式
     *
     * @param base64String base64String
     * @return
     */
    @TargetApi(Build.VERSION_CODES.O)
    public static byte[] base64ToByteArray(String base64String) {
        if (base64String == null) {
            return new byte[0];
        }
        Base64.Decoder decoder = Base64.getDecoder();
        return decoder.decode(base64String);
    }

    /**
     * 图片转换为base64格式
     *
     * @param bitmap 位图
     * @return
     */
    @TargetApi(Build.VERSION_CODES.O)
    public static String bitmapToBase64(Bitmap bitmap) {
        int size = bitmap.getWidth() * bitmap.getHeight() * 4;
        ByteArrayOutputStream baos = new ByteArrayOutputStream(size);
        try {
            //设置位图的压缩格式,质量为100%,并放入字节数组输出流中
            bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
            //将字节数组输出流转化为字节数组byte[]
            byte[] imageData = baos.toByteArray();
            Base64.Encoder encoder = Base64.getEncoder();
            return encoder.encodeToString(imageData);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
//                bitmap.recycle();
                baos.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return "";
    }


    /**
     * 根据角度值旋转Bitmap
     *
     * @param bitmap 位图对象
     * @param degree 旋转角度
     * @return bitmap 位图对象
     */
    public static Bitmap rotateBitmapByDegree(Bitmap bitmap, int degree) {

        // 根据旋转角度,得到旋转矩阵
        Matrix matrix = new Matrix();
        matrix.postRotate(degree);

        // 将原始图片按照旋转矩阵进行旋转,得到新的图片
        Bitmap result = null;
        try {
            result = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(),
                    bitmap.getHeight(), matrix, true);
        } catch (OutOfMemoryError e) {
            e.printStackTrace();
            result = bitmap;
        }

        if (bitmap != result) {
            bitmap.recycle();
        }
        return result;
    }

    /**
     * 得到bitmap的大小
     */
    public static int getBitmapSize(Bitmap bitmap) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {    //API 19
            return bitmap.getAllocationByteCount();
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {//API 12
            return bitmap.getByteCount();
        }
        // 在低版本中用一行的字节x高度
        return bitmap.getRowBytes() * bitmap.getHeight();                //earlier version
    }

}

3.2、DisplayUtil


/**
 * Description: 屏幕工具
 */
public class DisplayUtil {

    /**
     * 获取 LinearLayout的高度
     *
     * @param linearLayout 线性布局
     * @return 高度:像素值
     */
    public static int getLLWidth(LinearLayout linearLayout) {
        //measure方法的参数值都设为0即可
        linearLayout.measure(0, 0);
        //获取组件宽度
        int llWidth = linearLayout.getMeasuredWidth();
        return llWidth;
    }

    /**
     * 获取 LinearLayout的高度
     * @param linearLayout 线性布局
     * @return 高度:像素值
     */
    public static int getLLHeight(LinearLayout linearLayout) {
        //measure方法的参数值都设为0即可
        linearLayout.measure(0, 0);
        //获取组件高度
        int llHeight = linearLayout.getMeasuredHeight();
        return llHeight;
    }

    /**
     * 获取编辑区域高度:屏幕高度 - 状态栏高度 - 标题栏高度 - 导航栏高度
     *
     * @param context 上下文对象
     * @return 高度:像素值
     */
    public static int getEditAreaHeight(Context context) {
        //获取屏幕高度
        int screenHeight = getScreenHeightPx(context);

        //获取状态栏高度
        int statusBarHeight = getStatusBarHeight1(context);

        // 获取导航栏高度
        int navigationBarHeight = getNavigationBarHeight(context);

//        int editAreaHeight = screenHeight - statusBarHeight - navigationBarHeight;
        int editAreaHeight = screenHeight - statusBarHeight;

//        LogUtils.e("编辑区域高度:" + editAreaHeight);
        return editAreaHeight;
    }


    /**
     * 获取导航栏高度
     *
     * @param context 上下文对象
     * @return 高度:像素值
     */
    public static int getNavigationBarHeight(Context context) {
        int navigationBarHeight = -1;
        int resourceId = context.getResources().getIdentifier("navigation_bar_height",
                "dimen", "android");
        if (resourceId > 0) {
            navigationBarHeight = context.getResources().getDimensionPixelSize(resourceId);
        }
//        LogUtils.e("导航栏高度:" + navigationBarHeight);
        return navigationBarHeight;
    }

    /**
     * 获取状态栏高度——方法1
     *
     * @param context 上下文对象
     * @return 高度:像素值
     */
    public static int getStatusBarHeight1(Context context) {
        int statusBarHeight1 = -1;
        //获取status_bar_height资源的ID
        int resourceId = context.getResources().getIdentifier("status_bar_height",
                "dimen", "android");
        if (resourceId > 0) {
            //根据资源ID获取响应的尺寸值
            statusBarHeight1 = context.getResources().getDimensionPixelSize(resourceId);
        }
//        LogUtils.e("状态栏-方法1:" + statusBarHeight1);
        return statusBarHeight1;
    }

    /**
     * 获取状态栏高度——方法2
     *
     * @param context 上下文对象
     * @return 高度:像素值
     */
    public static int getStatusBarHeight2(Context context) {
        int statusBarHeight2 = -1;
        try {
            Class<?> clazz = Class.forName("com.android.internal.R$dimen");
            Object object = clazz.newInstance();
            int height = Integer.parseInt(clazz.getField("status_bar_height")
                    .get(object).toString());
            statusBarHeight2 = context.getResources().getDimensionPixelSize(height);
        } catch (Exception e) {
            e.printStackTrace();
        }
        LogUtils.e("状态栏-方法2:" + statusBarHeight2);

        return statusBarHeight2;
    }


    /**
     * 获取屏幕宽度
     *
     * @param context 上下文对象
     * @return 像素值
     */
    public static int getScreenWidthPx(Context context) {
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        DisplayMetrics dm = new DisplayMetrics();
        wm.getDefaultDisplay().getMetrics(dm);
        return dm.widthPixels;
    }

    /**
     * 获取屏幕高度
     *
     * @param context 上下文对象
     * @return 像素值
     */
    public static int getScreenHeightPx(Context context) {
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        DisplayMetrics dm = new DisplayMetrics();
        wm.getDefaultDisplay().getMetrics(dm);
        return dm.heightPixels;
    }

    /**
     * 屏幕宽度(dp)
     *
     * @param context 上下文对象
     * @return DP值
     */
    public static int getScreenWidthDp(Context context) {
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        DisplayMetrics dm = new DisplayMetrics();
        wm.getDefaultDisplay().getMetrics(dm);

        int width = dm.widthPixels;         // 屏幕宽度(像素)
        float density = dm.density;         // 屏幕密度(0.75 / 1.0 / 1.5)
        int screenWidth = (int) (width / density);  // 屏幕宽度(dp)

        return screenWidth;
    }

    /**
     * 屏幕高度(dp)
     *
     * @param context 上下文对象
     * @return DP值
     */
    public static int getScreenHeightDp(Context context) {
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        DisplayMetrics dm = new DisplayMetrics();
        wm.getDefaultDisplay().getMetrics(dm);

        int height = dm.heightPixels;       // 屏幕高度(像素)
        float density = dm.density;         // 屏幕密度(0.75 / 1.0 / 1.5)
        int screenHeight = (int) (height / density);// 屏幕高度(dp)

        return screenHeight;
    }

    /**
     * 密度(0.75 / 1.0 / 1.5)
     *
     * @param context
     * @return
     */
    public static float getScreenDensity(Context context) {
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        DisplayMetrics dm = new DisplayMetrics();
        wm.getDefaultDisplay().getMetrics(dm);
        return dm.density;
    }

    /**
     * 像素密度dpi(120 / 160 / 240)
     *
     * @param context
     * @return
     */
    public static float getScreenDensityDpi(Context context) {
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        DisplayMetrics dm = new DisplayMetrics();
        wm.getDefaultDisplay().getMetrics(dm);
        return dm.densityDpi;
    }

    /**
     * dp转px
     *
     * @param context 上下文
     * @param dpValue dp值
     * @return
     */
    public static int dip2px(Context context, float dpValue) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int) (dpValue * scale + 0.5f);
    }

    /**
     * px 转 dp
     *
     * @param context 上下文
     * @param pxValue px值
     * @return
     */
    public static int px2dip(Context context, float pxValue) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int) (pxValue / scale + 0.5f);
    }

    /**
     * 判断是否是刘海屏
     *
     * @return
     */
    public static boolean hasNotchScreen(Activity activity) {
        if (getInt("ro.miui.notch", activity) == 1 || hasNotchAtHuawei(activity) ||
                hasNotchAtOPPO(activity)
                || hasNotchAtVivo(activity) || isAndroidP(activity) != null) { //TODO 各种品牌
            return true;
        }

        return false;
    }

    /**
     * Android P 刘海屏判断
     *
     * @param activity
     * @return
     */
    public static DisplayCutout isAndroidP(Activity activity) {
        View decorView = activity.getWindow().getDecorView();
        if (decorView != null && android.os.Build.VERSION.SDK_INT >= 28) {
            WindowInsets windowInsets = decorView.getRootWindowInsets();
            if (windowInsets != null)
                return windowInsets.getDisplayCutout();
        }
        return null;
    }

    /**
     * 小米刘海屏判断.
     *
     * @return 0 if it is not notch ; return 1 means notch
     * @throws IllegalArgumentException if the key exceeds 32 characters
     */
    public static int getInt(String key, Activity activity) {
        int result = 0;

        try {
            ClassLoader classLoader = activity.getClassLoader();
            @SuppressWarnings("rawtypes")
            Class SystemProperties = classLoader.loadClass("android.os.SystemProperties");
            //参数类型
            @SuppressWarnings("rawtypes")
            Class[] paramTypes = new Class[2];
            paramTypes[0] = String.class;
            paramTypes[1] = int.class;
            Method getInt = SystemProperties.getMethod("getInt", paramTypes);
            //参数
            Object[] params = new Object[2];
            params[0] = new String(key);
            params[1] = new Integer(0);
            result = (Integer) getInt.invoke(SystemProperties, params);

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }

        return result;
    }

    /**
     * 华为刘海屏判断
     *
     * @return
     */
    public static boolean hasNotchAtHuawei(Context context) {
        boolean ret = false;
        try {
            ClassLoader classLoader = context.getClassLoader();
            Class HwNotchSizeUtil = classLoader.loadClass("com.huawei.android.util.HwNotchSizeUtil");
            Method get = HwNotchSizeUtil.getMethod("hasNotchInScreen");
            ret = (boolean) get.invoke(HwNotchSizeUtil);
        } catch (ClassNotFoundException e) {
            Log.e("Huawei", "hasNotchAtHuawei ClassNotFoundException");
        } catch (NoSuchMethodException e) {
            Log.e("Huawei", "hasNotchAtHuawei NoSuchMethodException");
        } catch (Exception e) {
            Log.e("Huawei", "hasNotchAtHuawei Exception");
        } finally {
            return ret;
        }
    }

    public static final int VIVO_NOTCH = 0x00000020;//是否有刘海
    public static final int VIVO_FILLET = 0x00000008;//是否有圆角

    /**
     * VIVO刘海屏判断
     *
     * @return
     */
    public static boolean hasNotchAtVivo(Context context) {
        boolean ret = false;
        try {
            ClassLoader classLoader = context.getClassLoader();
            Class FtFeature = classLoader.loadClass("android.util.FtFeature");
            Method method = FtFeature.getMethod("isFeatureSupport", int.class);
            ret = (boolean) method.invoke(FtFeature, VIVO_NOTCH);
        } catch (ClassNotFoundException e) {
            Log.e("Vivo", "hasNotchAtVivo ClassNotFoundException");
        } catch (NoSuchMethodException e) {
            Log.e("Vivo", "hasNotchAtVivo NoSuchMethodException");
        } catch (Exception e) {
            Log.e("Vivo", "hasNotchAtVivo Exception");
        } finally {
            return ret;
        }
    }

    /**
     * OPPO刘海屏判断
     *
     * @return
     */
    public static boolean hasNotchAtOPPO(Context context) {
        return context.getPackageManager().hasSystemFeature("com.oppo.feature.screen.heteromorphism");
    }
}

3.3、DistanceUtil


/**
 * on 2019/12/5.
 * 描述:根据经纬度计算距离
 */

public class DistanceUtil {

    /**
     * 沿经线(南北方向),经度不变,纬度变化约 1/111 度,这个要加减在纬度上
     * <p>
     * 经度上 1 千米 = 1 / 111 = 0.009009度
     */
    public static double oneKM2Lon = 0.009009;

    /**
     * 沿纬线(东西方向),纬度为a,纬度不变,经度变化约 1/(111*COSa)度,这个要加减在经度上
     * <p>
     * 纬度上1千米 = 1 / 111*cos(纬度) 
     *
     * @param latitude 纬度
     * @return double值
     */
    public static double oneKM2Lat(double latitude) {
        // 纬度上1千米 = 1 / 111*cos(纬度) 
        // 22.479265463306174 小数位太多需要保留六位小数
        double oneKM2Lat = 1 / (111 * Math.cos(Math.toRadians(latitude)));
        BigDecimal bg = new BigDecimal(oneKM2Lat);
        return bg.setScale(6, BigDecimal.ROUND_HALF_UP).doubleValue();
    }


}

3.4、LaunchTimer

public class LaunchTimer {
 
    private static long sTime;
 
    public static void startRecord() {
        sTime = System.currentTimeMillis();
    }
 
    public static void endRecord() {
        endRecord("");
    }
 
    public static void endRecord(String msg) {
        long cost = System.currentTimeMillis() - sTime;
        LogUtils.e(msg + " cost " + cost + "ms");
    }
 
}

3.5、LogUtils


/**
 * 类描述: Log工具类
 */
public class LogUtils {
    public static String TAG = "GS";
    public static boolean LOG_DEBUG = true;
    private static final String LINE_SEPARATOR = System.getProperty("line.separator");
    private static final int VERBOSE = 2;
    private static final int DEBUG = 3;
    private static final int INFO = 4;
    private static final int WARN = 5;
    private static final int ERROR = 6;
    private static final int ASSERT = 7;
    private static final int JSON = 8;
    private static final int XML = 9;

    private static final int JSON_INDENT = 4;

    public static void init(boolean isDebug, String tag) {
        TAG = tag;
        LOG_DEBUG = isDebug;
    }

    public static void v(String msg) {
        log(VERBOSE, null, msg);
    }

    public static void v(String tag, String msg) {
        log(VERBOSE, tag, msg);
    }

    public static void d(String msg) {
        log(DEBUG, null, msg);
    }

    public static void d(String tag, String msg) {
        log(DEBUG, tag, msg);
    }


    public static void i(String msg) {
        log(INFO, null, msg);
    }

    public static void i(String tag, String msg) {
        log(INFO, tag, msg);
    }

    public static void w(String msg) {
        log(WARN, null, msg);
    }

    public static void w(String tag, String msg) {
        log(WARN, tag, msg);
    }

    public static void e(String msg) {
        log(ERROR, null, msg);
    }

    public static void e(String tag, String msg) {
        log(ERROR, tag, msg);
    }

    public static void a(String msg) {
        log(ASSERT, null, msg);
    }

    public static void a(String tag, String msg) {
        log(ASSERT, tag, msg);
    }

    public static void json(String json) {
        log(JSON, null, json);
    }

    public static void json(String tag, String json) {
        log(JSON, tag, json);
    }

    public static void xml(String xml) {
        log(XML, null, xml);
    }

    public static void xml(String tag, String xml) {
        log(XML, tag, xml);
    }

    private static void log(int logType, String tagStr, Object objects) {
        String[] contents = wrapperContent(tagStr, objects);
        String tag = contents[0];
        String msg = contents[1];
        String headString = contents[2];
        if (LOG_DEBUG) {
            switch (logType) {
                case VERBOSE:
                case DEBUG:
                case INFO:
                case WARN:
                case ERROR:
                case ASSERT:
                    printDefault(logType, tag, headString + msg);
                    break;
                case JSON:
                    printJson(tag, msg, headString);
                    break;
                case XML:
                    printXml(tag, msg, headString);
                    break;
                default:
                    break;
            }
        }
    }

    private static void printDefault(int type, String tag, String msg) {
        if (TextUtils.isEmpty(tag)) {
            tag = TAG;
        }
        int index = 0;
        int maxLength = 4000;
        int countOfSub = msg.length() / maxLength;

        if (countOfSub > 0) {  // The log is so long
            for (int i = 0; i < countOfSub; i++) {
                String sub = msg.substring(index, index + maxLength);
                printSub(type, tag, sub);
                index += maxLength;
            }
            //printSub(type, msg.substring(index, msg.length()));
        } else {
            printSub(type, tag, msg);
        }

    }

    private static void printSub(int type, String tag, String sub) {
        if (tag == null) {
            tag = TAG;
        }
        switch (type) {
            case VERBOSE:
                Log.v(tag, sub);
                break;
            case DEBUG:
                Log.d(tag, sub);
                break;
            case INFO:
                Log.i(tag, sub);
                break;
            case WARN:
                Log.w(tag, sub);
                break;
            case ERROR:
                Log.e(tag, sub);
                break;
            case ASSERT:
                Log.wtf(tag, sub);
                break;
        }
    }

    private static void printJson(String tag, String json, String headString) {
        if (TextUtils.isEmpty(json)) {
            d("Empty/Null json content");
            return;
        }
        if (TextUtils.isEmpty(tag)) {
            tag = TAG;
        }
        String message;

        try {
            if (json.startsWith("{")) {
                JSONObject jsonObject = new JSONObject(json);
                message = jsonObject.toString(JSON_INDENT);
            } else if (json.startsWith("[")) {
                JSONArray jsonArray = new JSONArray(json);
                message = jsonArray.toString(JSON_INDENT);
            } else {
                message = json;
            }
        } catch (JSONException e) {
            message = json;
        }

        printLine(tag, true);
        message = headString + LINE_SEPARATOR + message;
        String[] lines = message.split(LINE_SEPARATOR);
        for (String line : lines) {
            Log.d(tag, "|" + line);
        }
        printLine(tag, false);
    }

    private static void printXml(String tag, String xml, String headString) {
        if (TextUtils.isEmpty(tag)) {
            tag = TAG;
        }
        if (xml != null) {
            try {
                Source xmlInput = new StreamSource(new StringReader(xml));
                StreamResult xmlOutput = new StreamResult(new StringWriter());
                Transformer transformer = TransformerFactory.newInstance().newTransformer();
                transformer.setOutputProperty(OutputKeys.INDENT, "yes");
                transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
                transformer.transform(xmlInput, xmlOutput);
                xml = xmlOutput.getWriter().toString().replaceFirst(">", ">\n");
            } catch (Exception e) {
                e.printStackTrace();
            }
            xml = headString + "\n" + xml;
        } else {
            xml = headString + "Log with null object";
        }

        printLine(tag, true);
        String[] lines = xml.split(LINE_SEPARATOR);
        for (String line : lines) {
            if (!TextUtils.isEmpty(line)) {
                Log.d(tag, "|" + line);
            }
        }
        printLine(tag, false);
    }

    private static String[] wrapperContent(String tag, Object... objects) {
        if (TextUtils.isEmpty(tag)) {
            tag = TAG;
        }
        StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
        StackTraceElement targetElement = stackTrace[5];
//        String className = targetElement.getClassName();
        String fileName = targetElement.getFileName();
//        String[] classNameInfo = className.split("\\.");
//        if (classNameInfo.length > 0) {
//            className = classNameInfo[classNameInfo.length - 1] + ".java";
//        }
        String methodName = targetElement.getMethodName();
        int lineNumber = targetElement.getLineNumber();
        if (lineNumber < 0) {
            lineNumber = 0;
        }
        String methodNameShort = methodName.substring(0, 1).toUpperCase() + methodName.substring(1);
        String msg = (objects == null) ? "Log with null object" : getObjectsString(objects);
//        String headString = "[(" + className + ":" + lineNumber + ")#" + methodNameShort + " ] ";
        String headString = "[(" + fileName + ":" + lineNumber + ")#" + methodNameShort + " ] ";
        return new String[]{tag, msg, headString};
    }

    private static String getObjectsString(Object... objects) {

        if (objects.length > 1) {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append("\n");
            for (int i = 0; i < objects.length; i++) {
                Object object = objects[i];
                if (object == null) {
                    stringBuilder.append("param").append("[").append(i).append("]").append(" = ").append("null").append("\n");
                } else {
                    stringBuilder.append("param").append("[").append(i).append("]").append(" = ").append(object.toString()).append("\n");
                }
            }
            return stringBuilder.toString();
        } else {
            Object object = objects[0];
            return object == null ? "null" : object.toString();
        }
    }

    public static void printLine(String tag, boolean isTop) {
        if (isTop) {
            Log.d(tag, "╔═══════════════════════════════════════════════════════════════════════════════════════");
        } else {
            Log.d(tag, "╚═══════════════════════════════════════════════════════════════════════════════════════");
        }
    }
}

3.6、TimeUtils


/**
 * 时间工具类
 */
public class TimeUtils {

    public static String changeTimeMillisToDate(long timeMillis){
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss ");
        Date date = new Date(timeMillis);
        String str = formatter.format(date);
        return str;
    }

    public static String getCurrentTime() {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ");
        Date curDate = new Date(System.currentTimeMillis());//获取当前时间
        String str = formatter.format(curDate);
        return str;
    }

    public static String getCurrentTime2() {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss ");
        Date curDate = new Date(System.currentTimeMillis());//获取当前时间
        String str = formatter.format(curDate);
        return str;
    }

    public static String getCurrentYearMonthDay() {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        Date curDate = new Date(System.currentTimeMillis());//获取当前时间
        String str = formatter.format(curDate);
        return str;
    }

    public static String getCurrentYear() {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy年MM月");
        Date curDate = new Date(System.currentTimeMillis());//获取当前时间
        String str = formatter.format(curDate);
        return str;
    }

    public static String getYear() {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy");
        Date curDate = new Date(System.currentTimeMillis());//获取当前时间
        String str = formatter.format(curDate);
        return str;
    }

    public static String getMonth() {
        SimpleDateFormat formatter = new SimpleDateFormat("MM");
        Date curDate = new Date(System.currentTimeMillis());//获取当前时间
        String str = formatter.format(curDate);
        return str;
    }
}

4、sql

4.1、SqliteConstant


/**
 * on 2019/11/25.
 * 常量
 */

public class SqliteConstant {

    //用以判断是否采集数据
    public static final boolean IS_OPEN_COLLECT_DATA = false;

    public static final String DATABASE_NAME = "rdd.db";//数据库名称

    /**
     * 2.21 表 rdd_images 新加入参数 IS_UPLOADED和CAPTURE_TIME 升级版本号为3
     * 测试一下,版本号升为4:修改字段后或者增加字段后把原有表都删除,再新建表
     */
    public static final int DATABASE_VERSION = 4;//数据库版本号

    /**
     * -----------表名 rdd_images  用于存储识别的图片信息 ---------start-----------
     * 及其字段名
     */
    public static final String TABLE_RDD_IMAGES = "rdd_images";

    //表rdd_images的字段名
    //图片ID,也是主键ID;数据类型:varchar(50),使用Java的UUID,即一个随机生成的字符串;必须有数据;
    public static final String IMAGE_ID = "image_id";

    //图片;数据类型:blob;必须有数据
    public static final String IMAGE = "image";

    //图片偏转角度;数据类型:double;数据可有可无
    public static final String ANGLE = "angle";

    //图片宽度;数据类型:double;必须有数据
    public static final String WIDTH = "width";

    //图片高度;数据类型:double;必须有数据
    public static final String HEIGHT = "height";

    //设备分辨率宽度;数据类型:double;数据可有可无
    public static final String DPI_WIDTH = "dpi_width";

    //设备分辨率高度;数据类型:double;数据可有可无
    public static final String DPI_HEIGHT = "dpi_height";

    //地图类型;数据类型:varchar;必须有数据
    public static final String GEO_MAP_INFO = "geo_map_info";
    //距地地图类型
    public static final String GD_MAP = "gd_map";//高德地图
    public static final String BD_MAP = "bd_map";//百度地图
    public static final String TC_MAP = "tc_map";//腾讯地图
    public static final String GG_MAP = "gg_map";//谷歌地图
    public static final String OTHER_MAP = "other_map";//其他地图

    //经度;数据类型:double;必须有数据
    public static final String LONGITUDE = "longitude";

    //纬度;数据类型:double;必须有数据
    public static final String LATITUDE = "latitude";

    //海拔高度;数据类型:double;数据可有可无
    public static final String ALTITUDE = "altitude";

    //创建者;数据类型:int;必须有数据 (此处考虑为登陆的用户ID,先默认为1)
    public static final String CREATED_BY = "created_by";

    //创建时间;数据类型:long ;必须有数据
    public static final String CREATION_DATE = "creation_date";

    //最后修改者;数据类型:int;必须有数据  (此处考虑为登陆的用户ID,先默认为1)
    public static final String LAST_UPDATED_BY = "last_updated_by";

    //最后修改时间;数据类型:int;必须有数据
    public static final String LAST_UPDATED_DATE = "last_updated_date";

    //图片的街道信息:数据类型:varchar(100);必须有数据
    public static final String STREET = "street";

    //图片详细的地址信息:数据类型:varchar(255);必须有数据
    public static final String ADDRESS = "address";

    //图片标记,用以标记是否上传到服务器;数据类型:int(0为false,1为true);  必须有数据
    public static final String IS_IMAGE_UPLOADED = "is_image_uploaded";

    //图片采集时间;数据类型:int;必须有数据
    public static final String CAPTURE_TIME = "capture_time";

    /*** -----------表名 rdd_images  用于存储识别的图片信息-----------end-----------*/


    /**
     * -----------表名 rdd_image_damages  用于存储识别图片的病害信息 ---------start-----------
     * 及其字段名
     */
    public static final String TABLE_RDD_IMAGE_DAMAGES = "rdd_image_damages";

    //病害ID,此处作为主键;数据类型:varchar(50);必须有数据;
    public static final String DAMAGE_ID = "damage_id";

    //图片ID,此处作为外键;数据类型:varchar(50);必须有数据;
//    public static final String IMAGE_ID = "image_id";

    //病害码,此处作为外键;数据类型:varchar(20);必须有数据;
//    public static final String DAMAGE_CODE = "damage_code";

    //概率,此处作为外键;数据类型:float;数据可有可无;
    public static final String CONFIDENT = "confident";

    //矩形框左侧的X坐标;数据类型:float;数据可有可无;
    public static final String DAMAGE_LEFT = "damage_left";

    //矩形框上侧的Y坐标;数据类型:float;数据可有可无;
    public static final String DAMAGE_TOP = "damage_top";

    //矩形框右侧的X坐标;数据类型:float;数据可有可无;
    public static final String DAMAGE_RIGHT = "damage_right";

    //矩形框下侧的Y坐标;数据类型:float;数据可有可无;
    public static final String DAMAGE_BOTTOM = "damage_bottom";

    //病害标记,用以标记是否上传到服务器;数据类型:int(0为false,1为true);  必须有数据
    public static final String IS_DAMAGE_UPLOADED = "is_damage_uploaded";

    // 病害采集时间,用以查询时进行排序: 数据类型:long;必须有数据;
    // 备注:只是本地查询时使用,不做他用
    public static final String DAMAGE_CAPTURE_TIME = "damage_capture_time";

    //描述暂时未知;数据类型:未知;数据可有可无;
    public static final String WHO = "who";

    /** -----------表名 rdd_image_damages  用于存储识别图片的病害信息 ---------end-----------*/


    /**
     * -----------表名 rdd_damages  用于存储病害信息(病害类型、病害描述、解决方案等) ---------start-----------
     * 及其字段名
     */
    public static final String TABLE_RDD_DAMAGES = "rdd_damages";

    //病害码,也是主键ID;数据类型:varchar(20);必须有数据;
    public static final String DAMAGE_CODE = "damage_code";

    //病害名称;数据类型:varchar;数据可有可无
    public static final String DAMAGE_NAME = "damage_name";

    //病害描述;数据类型:varchar;数据可有可无
    public static final String DAMAGE_DESC = "damage_desc";

    //病害解决方案;数据类型:varchar;数据可有可无   resolution:解决方案
    public static final String DAMAGE_RESO = "damage_reso";

    /*** -----------表名 rdd_damages  用于存储病害信息(病害类型、病害描述、解决方案等) ---------end-----------*/

}

4.2、MySqliteHelper


/**
 * on 2019/11/25.
 */

public class MySqliteHelper extends SQLiteOpenHelper {

    public MySqliteHelper(Context context) {
        super(context, SqliteConstant.DATABASE_NAME, null, SqliteConstant.DATABASE_VERSION);
    }

    public MySqliteHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    /**
     * 当数据库版本更新时回调的函数
     * <p>
     * 修改字段后或者增加字段后把原有表都删除,再新建表,避免每次修改表都要卸载APP的麻烦操作
     *
     * @param db         数据库对象
     * @param oldVersion 数据库的老版本
     * @param newVersion 数据库的新版本
     */
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        LogUtils.e("onUpgrade");
        String sql1 = "drop table if exists " + SqliteConstant.TABLE_RDD_IMAGES;
        String sql2 = "drop table if exists " + SqliteConstant.TABLE_RDD_IMAGE_DAMAGES;
        String sql3 = "drop table if exists " + SqliteConstant.TABLE_RDD_DAMAGES;
        db.execSQL(sql1);
        db.execSQL(sql2);
        db.execSQL(sql3);
        onCreate(db);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        LogUtils.e("onCreate");
        createTableRddImages(db);
        createTableRddImageDamages(db);
        createTableRddDamages(db);
    }

    /**
     * 创建表  表名 rdd_damages  用于存储病害信息(病害类型、病害描述、解决方案等)
     *
     * @param db 数据库对象
     */
    private void createTableRddDamages(SQLiteDatabase db) {
//        String sql = "create table rdd_damages (" +
//                "damage_code varchar(20) primary key not null," +
//                "damage_name varchar," +
//                "damage_desc varchar," +
//                "damage_reso varchar)";

        String sql = "create table " +
                SqliteConstant.TABLE_RDD_DAMAGES + " (" +
                SqliteConstant.DAMAGE_CODE + " varchar(20) primary key not null," +
                SqliteConstant.DAMAGE_NAME + " varchar," +
                SqliteConstant.DAMAGE_DESC + " varchar," +
                SqliteConstant.DAMAGE_RESO + " varchar)";
        db.execSQL(sql);//执行sql语句
    }

    /**
     * 创建表  表名 rdd_image_damages  用于存储识别图片的病害信息
     *
     * @param db 数据库对象
     */
    private void createTableRddImageDamages(SQLiteDatabase db) {
//        String sql = "create table rdd_image_damages (" +
//                "image_id varchar(50) not null," +
//                "damage_code varchar(20) not null," +
//                "confident float," +
//                "left float," +
//                "top float," +
//                "right float," +
//                "bottom float)";

        String sql = "create table " +
                SqliteConstant.TABLE_RDD_IMAGE_DAMAGES + " (" +
                SqliteConstant.DAMAGE_ID + " varchar(50) primary key not null, " +
                SqliteConstant.IMAGE_ID + " varchar(50) not null, " +
                SqliteConstant.DAMAGE_CODE + " varchar(20) not null, " +
                SqliteConstant.CONFIDENT + " number, " +
                SqliteConstant.DAMAGE_LEFT + " number, " +
                SqliteConstant.DAMAGE_TOP + " number, " +
                SqliteConstant.DAMAGE_RIGHT + " number, " +
                SqliteConstant.DAMAGE_BOTTOM + " number, " +
                SqliteConstant.IS_DAMAGE_UPLOADED + " number, " +
                SqliteConstant.DAMAGE_CAPTURE_TIME + " number" +
                ")";
        db.execSQL(sql);//执行sql语句
    }


    /**
     * 创建表  表名 rdd_images  用于存储识别的图片信息
     *
     * @param db 数据库对象
     */
    private void createTableRddImages(SQLiteDatabase db) {
//        String sql = "create table rdd_images (" +
//                "image_id varchar(50) primary key not null," +
//                "image blob not null," +
//                "angle double not null," +
//                "width double not null," +
//                "height double not null," +
//                "dpi_width double," +
//                "dpi_height double," +
//                "geo_map varchar(20) not null," +
//                "longitude double not null," +
//                "latitude double not null," +
//                "altitude double," +
//                "created_by integer," +
//                "creation_date varchar(30)," +
//                "last_updated_by integer," +
//                "last_updated_date varchar(30)," +
//                "street varchar(100)," +
//                "address varchar(255))";

        String sql = "create table " +
                SqliteConstant.TABLE_RDD_IMAGES + " (" +
                SqliteConstant.IMAGE_ID + " varchar(50) primary key not null," +
                SqliteConstant.IMAGE + " blob not null," +
                SqliteConstant.ANGLE + " number not null," +
                SqliteConstant.WIDTH + " number not null," +
                SqliteConstant.HEIGHT + " number not null," +
                SqliteConstant.DPI_WIDTH + " number," +
                SqliteConstant.DPI_HEIGHT + " number," +
                SqliteConstant.GEO_MAP_INFO + " varchar(20) not null," +
                SqliteConstant.LONGITUDE + " number not null," +
                SqliteConstant.LATITUDE + " number not null," +
                SqliteConstant.ALTITUDE + " number," +
                SqliteConstant.CREATED_BY + " number," +
                SqliteConstant.CREATION_DATE + " varchar(30)," +
                SqliteConstant.LAST_UPDATED_BY + " number," +
                SqliteConstant.LAST_UPDATED_DATE + " varchar(30)," +
                SqliteConstant.STREET + " varchar(100)," +
                SqliteConstant.ADDRESS + " varchar(255)," +
                SqliteConstant.IS_IMAGE_UPLOADED + " number," +
                SqliteConstant.CAPTURE_TIME + " number" +
                ")";
        db.execSQL(sql);//执行sql语句

    }


    /**
     * 当数据库打开时回调的函数
     *
     * @param db 数据库对象
     */
    @Override
    public void onOpen(SQLiteDatabase db) {
        LogUtils.d("onOpen");
        super.onOpen(db);
    }
}

4.3、DbManager


/**
 * on 2019/11/25.
 * 对数据库操作的工具类
 */

public class DbManager {

    private static MySqliteHelper helper;

    public static MySqliteHelper getInstance(Context context) {
        if (helper == null) {
            helper = new MySqliteHelper(context);
        }
        return helper;
    }

    /**
     * 根据 imageId 从表 rdd_image_damages 查询出信息 的个数
     *
     * @param db      数据库对象
     * @param imageId imageId
     * @return
     */
    public static int queryGetCount(SQLiteDatabase db, String imageId) {
//        String sql = "SELECT COUNT(image_id) FROM rdd_image_damages WHERE image_id =  \"imageId\" ";

        String sql = "SELECT COUNT(" + SqliteConstant.IMAGE_ID + ") " +
                "FROM " + SqliteConstant.TABLE_RDD_IMAGE_DAMAGES +
                " WHERE " + SqliteConstant.IMAGE_ID + " = \"" + imageId + "\"";

        Cursor cursor = db.rawQuery(sql, null);
        cursor.moveToFirst();
        int count = cursor.getInt(0);
        cursor.close();
        LogUtils.e("count:" + count);
        return count;
    }

    /**
     * 根据地图当前中心点的经纬度 查询 5公里矩形范围内的病害信息的经纬度
     *
     * @param db        数据库对象
     * @param longitude 经度
     * @param latitude  纬度
     */
    public static List<LatLng> queryLonLatInCertainArea(SQLiteDatabase db,
                                                        double longitude, double latitude) {
        List<LatLng> list = new ArrayList<>();

        double fromLongitude = longitude - DistanceUtil.oneKM2Lat(latitude) * 5;
        double toLongitude = longitude + DistanceUtil.oneKM2Lat(latitude) * 5;

        double fromLatitude = latitude - DistanceUtil.oneKM2Lon * 5;
        double toLatitude = latitude + DistanceUtil.oneKM2Lon * 5;

//        String sql2 = "SELECT longitude,latitude FROM rdd_images WHERE longitude BETWEEN fromLongitude" +
//                " AND toLongitude AND latitude BETWEEN fromLatitude AND toLatitude";
        String sql = "SELECT " + SqliteConstant.LONGITUDE + " , " + SqliteConstant.LATITUDE +
                " FROM  " + SqliteConstant.TABLE_RDD_IMAGES +
                " WHERE " + SqliteConstant.LONGITUDE + " BETWEEN " + fromLongitude + " AND " + toLongitude +
                " AND " + SqliteConstant.LATITUDE + " BETWEEN " + fromLatitude + " AND " + toLatitude;

        Cursor cursor = db.rawQuery(sql, null);
        while (cursor.moveToNext()) {
            double longitudeReturn = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.LONGITUDE));
            double latitudeReturn = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.LATITUDE));

            LatLng bean = new LatLng(latitudeReturn, longitudeReturn);
            list.add(bean);
        }
        cursor.close();
        return list;
    }

    /**
     * 根据经纬度查询该经纬度的所有病害信息
     * 两个表联合查询
     * <p>
     * 表一:rdd_images
     * 表二:rdd_image_damages
     *
     * @param db        数据库对象
     * @param longitude 经度
     * @param latitude  纬度
     * @return list列表
     */
    public static ArrayList<ImageDamageVo> queryImageByLongitude(SQLiteDatabase db, double longitude,
                                                                 double latitude) {
        String sql = "SELECT rdd_images.image_id, rdd_images.image, rdd_images.angle," +
                "rdd_images.creation_date, rdd_images.street, rdd_images.address," +
                "rdd_image_damages.damage_id, rdd_image_damages.damage_code, " +
                "rdd_image_damages.confident, " +
                "rdd_image_damages.left, rdd_image_damages.top, " +
                "rdd_image_damages.right, rdd_image_damages.bottom " +
                "FROM rdd_images, rdd_image_damages " +
                "WHERE rdd_images.image_id = rdd_image_damages.image_id " +
                " AND " + SqliteConstant.LONGITUDE + " = " + longitude +
                " AND " + SqliteConstant.LATITUDE + " = " + latitude +
                " ORDER BY " + SqliteConstant.CREATION_DATE + " DESC" +
                " LIMIT 10";

        Cursor cursor = db.rawQuery(sql, null);

        ArrayList<ImageDamageVo> list = new ArrayList<>();
        while (cursor.moveToNext()) {
            String imageId = cursor.getString(cursor.getColumnIndex(SqliteConstant.IMAGE_ID));
            byte[] imageData = cursor.getBlob(cursor.getColumnIndex(SqliteConstant.IMAGE));
            double angle = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.ANGLE));
            long creationDate = cursor.getLong(cursor.getColumnIndex(SqliteConstant.CREATION_DATE));
            String street = cursor.getString(cursor.getColumnIndex(SqliteConstant.STREET));
            String address = cursor.getString(cursor.getColumnIndex(SqliteConstant.ADDRESS));

            String damageId = cursor.getString(cursor.getColumnIndex(SqliteConstant.DAMAGE_ID));
            String damageCode = cursor.getString(cursor.getColumnIndex(SqliteConstant.DAMAGE_CODE));
            float confident = cursor.getFloat(cursor.getColumnIndex(SqliteConstant.CONFIDENT));
            float damageLeft = cursor.getFloat(cursor.getColumnIndex(SqliteConstant.DAMAGE_LEFT));
            float damageTop = cursor.getFloat(cursor.getColumnIndex(SqliteConstant.DAMAGE_TOP));
            float damageRight = cursor.getFloat(cursor.getColumnIndex(SqliteConstant.DAMAGE_RIGHT));
            float damageBottom = cursor.getFloat(cursor.getColumnIndex(SqliteConstant.DAMAGE_BOTTOM));

            ImageDamageVo imageDamageVo = new ImageDamageVo();
            imageDamageVo.setImageId(imageId);
            imageDamageVo.setImageData(imageData);
            imageDamageVo.setAngle(angle);
            imageDamageVo.setCreationDate(creationDate);
            imageDamageVo.setStreet(street);
            imageDamageVo.setAddress(address);
            imageDamageVo.setDamageId(damageId);
            imageDamageVo.setDamageCode(damageCode);
            imageDamageVo.setConfident(confident);
            imageDamageVo.setDamageLeft(damageLeft);
            imageDamageVo.setDamageTop(damageTop);
            imageDamageVo.setDamageRight(damageRight);
            imageDamageVo.setDamageBottom(damageBottom);
//            LogUtils.d(imageDamageVo.toString());
            list.add(imageDamageVo);
        }
        cursor.close();
        return list;
    }

    /**
     * 从本地数据库的表 TABLE_RDD_IMAGE_DAMAGES 中查询一条数据并返回
     *
     * @param db 数据库对象
     * @return CaptureImageDamage 查询获得的结果
     */
    public static CaptureImageDamage queryRddImageDamage(SQLiteDatabase db) {
        String sql = "SELECT " + SqliteConstant.DAMAGE_ID + " , " + SqliteConstant.IMAGE_ID + " , " +
                SqliteConstant.DAMAGE_CODE + " , " + SqliteConstant.CONFIDENT + " , " + SqliteConstant.DAMAGE_LEFT + " , " +
                SqliteConstant.DAMAGE_TOP + " , " + SqliteConstant.DAMAGE_RIGHT + " , " + SqliteConstant.DAMAGE_BOTTOM +
                " FROM  " + SqliteConstant.TABLE_RDD_IMAGE_DAMAGES +
                " WHERE " + SqliteConstant.IS_DAMAGE_UPLOADED + " = 0 " +
                " ORDER BY " + SqliteConstant.DAMAGE_CAPTURE_TIME + " ASC" +
                " LIMIT 1";
        Cursor cursor = db.rawQuery(sql, null);
        CaptureImageDamage captureImageDamage = new CaptureImageDamage();
        while (cursor.moveToNext()) {
            String damageId = cursor.getString(cursor.getColumnIndex(SqliteConstant.DAMAGE_ID));
            String imageId = cursor.getString(cursor.getColumnIndex(SqliteConstant.IMAGE_ID));
            String damageCode = cursor.getString(cursor.getColumnIndex(SqliteConstant.DAMAGE_CODE));
            double confident = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.CONFIDENT));
            double left = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.DAMAGE_LEFT));
            double top = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.DAMAGE_TOP));
            double right = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.DAMAGE_RIGHT));
            double bottom = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.DAMAGE_BOTTOM));

            captureImageDamage.setDamageId(damageId);
            captureImageDamage.setImageId(imageId);
            captureImageDamage.setDamageCode(damageCode);
            captureImageDamage.setConfident(confident);
            captureImageDamage.setDamageLeft(left);
            captureImageDamage.setDamageTop(top);
            captureImageDamage.setDamageRight(right);
            captureImageDamage.setDamageBottom(bottom);

//            LogUtils.d(captureImageDamage.toString());
        }
        cursor.close();
        return captureImageDamage;
    }

    /**
     * 从本地数据库的表 TABLE_RDD_IMAGE_DAMAGES 中查询十条未上传的数据,放到一个列表中
     *
     * @param db 数据库对象
     * @return list
     */
    public static ArrayList<CaptureImageDamage> queryRddImageDamageList(SQLiteDatabase db) {
        String sql = "SELECT " + SqliteConstant.DAMAGE_ID + " , " + SqliteConstant.IMAGE_ID + " , " +
                SqliteConstant.DAMAGE_CODE + " , " + SqliteConstant.CONFIDENT + " , " + SqliteConstant.DAMAGE_LEFT + " , " +
                SqliteConstant.DAMAGE_TOP + " , " + SqliteConstant.DAMAGE_RIGHT + " , " + SqliteConstant.DAMAGE_BOTTOM +
                " FROM  " + SqliteConstant.TABLE_RDD_IMAGE_DAMAGES +
                " WHERE " + SqliteConstant.IS_DAMAGE_UPLOADED + " = 0 " +
                " LIMIT 10";
        Cursor cursor = db.rawQuery(sql, null);
        ArrayList<CaptureImageDamage> list = new ArrayList<>();
        while (cursor.moveToNext()) {
            String damageId = cursor.getString(cursor.getColumnIndex(SqliteConstant.DAMAGE_ID));
            String imageId = cursor.getString(cursor.getColumnIndex(SqliteConstant.IMAGE_ID));
            String damageCode = cursor.getString(cursor.getColumnIndex(SqliteConstant.DAMAGE_CODE));
            double confident = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.CONFIDENT));
            double left = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.DAMAGE_LEFT));
            double top = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.DAMAGE_TOP));
            double right = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.DAMAGE_RIGHT));
            double bottom = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.DAMAGE_BOTTOM));

            CaptureImageDamage captureImageDamage = new CaptureImageDamage();
            captureImageDamage.setDamageId(damageId);
            captureImageDamage.setImageId(imageId);
            captureImageDamage.setDamageCode(damageCode);
            captureImageDamage.setConfident(confident);
            captureImageDamage.setDamageLeft(left);
            captureImageDamage.setDamageTop(top);
            captureImageDamage.setDamageRight(right);
            captureImageDamage.setDamageBottom(bottom);

            list.add(captureImageDamage);
//            LogUtils.d(list.size() + "");
        }
        cursor.close();
        return list;
    }

    /**
     * 从本地数据库的表 TABLE_RDD_IMAGES 中查询 1条未上传的数据并返回
     *
     * @param db 数据库对象
     * @return CaptureImage
     */
    public static CaptureImage queryRddImage(SQLiteDatabase db) {
        String sql = "SELECT " + SqliteConstant.IMAGE_ID + " , " + SqliteConstant.IMAGE + " , " +
                SqliteConstant.ANGLE + " , " + SqliteConstant.WIDTH + " , " + SqliteConstant.HEIGHT + " , " +
                SqliteConstant.DPI_WIDTH + " , " + SqliteConstant.DPI_HEIGHT + " , " + SqliteConstant.GEO_MAP_INFO + " , " +
                SqliteConstant.LONGITUDE + " , " + SqliteConstant.LATITUDE + " , " + SqliteConstant.STREET + " , " +
                SqliteConstant.ADDRESS + " , " + SqliteConstant.ALTITUDE + " , " + SqliteConstant.CAPTURE_TIME +
                " FROM  " + SqliteConstant.TABLE_RDD_IMAGES +
                " WHERE " + SqliteConstant.IS_IMAGE_UPLOADED + " = 0 " +
                " LIMIT 1";
        Cursor cursor = db.rawQuery(sql, null);
        CaptureImage captureImage = new CaptureImage();
        while (cursor.moveToNext()) {
            String imageId = cursor.getString(cursor.getColumnIndex(SqliteConstant.IMAGE_ID));
            byte[] image = cursor.getBlob(cursor.getColumnIndex(SqliteConstant.IMAGE));
            double angle = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.ANGLE));
            double width = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.WIDTH));
            double height = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.HEIGHT));
            double dpiWidth = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.DPI_WIDTH));
            double dpiHeight = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.DPI_HEIGHT));
            String geoMapInfo = cursor.getString(cursor.getColumnIndex(SqliteConstant.GEO_MAP_INFO));
            double longitude = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.LONGITUDE));
            double latitude = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.LATITUDE));
            double altitude = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.ALTITUDE));
            String address = cursor.getString(cursor.getColumnIndex(SqliteConstant.ADDRESS));
            String street = cursor.getString(cursor.getColumnIndex(SqliteConstant.STREET));
            long captureTime = cursor.getLong(cursor.getColumnIndex(SqliteConstant.CAPTURE_TIME));

            String imageDataBase64 = BitmapUtils.byteArrayToBase64(image);

            captureImage.setImageId(imageId);
            captureImage.setImage(imageDataBase64);
            captureImage.setAngle(angle);
            captureImage.setWidth(width);
            captureImage.setHeight(height);
            captureImage.setDpiWidth(dpiWidth);
            captureImage.setDpiHeight(dpiHeight);
            captureImage.setGeoMapInfo(geoMapInfo);
            captureImage.setLongitude(longitude);
            captureImage.setLatitude(latitude);
            captureImage.setAltitude(altitude);
            captureImage.setStreet(street);
            captureImage.setAddress(address);
            captureImage.setCaptureTime(String.valueOf(captureTime));
        }
        cursor.close();
        return captureImage;
    }

    /**
     * 从本地数据库的表 TABLE_RDD_IMAGES 中查询十条未上传的数据,放到一个列表中
     *
     * @param db 数据库对象
     * @return list
     */
    public static ArrayList<CaptureImage> queryRddImageList(SQLiteDatabase db) {
        String sql = "SELECT " + SqliteConstant.IMAGE_ID + " , " + SqliteConstant.IMAGE + " , " +
                SqliteConstant.ANGLE + " , " + SqliteConstant.WIDTH + " , " + SqliteConstant.HEIGHT + " , " +
                SqliteConstant.DPI_WIDTH + " , " + SqliteConstant.DPI_HEIGHT + " , " + SqliteConstant.GEO_MAP_INFO + " , " +
                SqliteConstant.LONGITUDE + " , " + SqliteConstant.LATITUDE + " , " + SqliteConstant.STREET + " , " +
                SqliteConstant.ADDRESS + " , " + SqliteConstant.ALTITUDE + " , " + SqliteConstant.CAPTURE_TIME +
                " FROM  " + SqliteConstant.TABLE_RDD_IMAGES +
                " WHERE " + SqliteConstant.IS_IMAGE_UPLOADED + " = 0 " +
                " LIMIT 10";
        Cursor cursor = db.rawQuery(sql, null);
        ArrayList<CaptureImage> list = new ArrayList<>();
        while (cursor.moveToNext()) {
            String imageId = cursor.getString(cursor.getColumnIndex(SqliteConstant.IMAGE_ID));
            byte[] image = cursor.getBlob(cursor.getColumnIndex(SqliteConstant.IMAGE));
            double angle = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.ANGLE));
            double width = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.WIDTH));
            double height = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.HEIGHT));
            double dpiWidth = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.DPI_WIDTH));
            double dpiHeight = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.DPI_HEIGHT));
            String geoMapInfo = cursor.getString(cursor.getColumnIndex(SqliteConstant.GEO_MAP_INFO));
            double longitude = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.LONGITUDE));
            double latitude = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.LATITUDE));
            double altitude = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.ALTITUDE));
            String address = cursor.getString(cursor.getColumnIndex(SqliteConstant.ADDRESS));
            String street = cursor.getString(cursor.getColumnIndex(SqliteConstant.STREET));
            long captureTime = cursor.getLong(cursor.getColumnIndex(SqliteConstant.CAPTURE_TIME));

            String imageDataBase64 = BitmapUtils.byteArrayToBase64(image);

            CaptureImage captureImage = new CaptureImage();
            captureImage.setImageId(imageId);
            captureImage.setImage(imageDataBase64);
            captureImage.setAngle(angle);
            captureImage.setWidth(width);
            captureImage.setHeight(height);
            captureImage.setDpiWidth(dpiWidth);
            captureImage.setDpiHeight(dpiHeight);
            captureImage.setGeoMapInfo(geoMapInfo);
            captureImage.setLongitude(longitude);
            captureImage.setLatitude(latitude);
            captureImage.setAltitude(altitude);
            captureImage.setStreet(street);
            captureImage.setAddress(address);
            captureImage.setCaptureTime(String.valueOf(captureTime));

            list.add(captureImage);
//            LogUtils.d(rddImage.toString());
//            LogUtils.d(list.size() + "");
        }
        cursor.close();
        return list;
    }

    /**
     * 根据 damageId 将数据库 表TABLE_RDD_IMAGE_DAMAGES
     *
     * @param db       数据库对象
     * @param damageId damageId
     */
    public static void updateIsDamageUploaded(SQLiteDatabase db, String damageId) {
        String sql = "UPDATE " + SqliteConstant.TABLE_RDD_IMAGE_DAMAGES + " SET " +
                SqliteConstant.IS_DAMAGE_UPLOADED + " = 1"
                + " WHERE " + SqliteConstant.DAMAGE_ID + " = \"" + damageId + "\""; // 1 or 1 = 1
        db.execSQL(sql);
        LogUtils.d("更新 is_damage_uploaded 成功");
    }

    /**
     * 根据 imageIdList 将数据库中的相应数据的 isUploaded 属性改为1(表示已上传)
     *
     * @param db          数据库对象
     * @param imageIdList imageIdList
     */
    public static void updateIsImageUploaded(SQLiteDatabase db, List<String> imageIdList) {
//        UPDATE Person SET FirstName = 'Fred' WHERE LastName = 'Wilson'
//        String sql = "UPDATE rdd_images SET is_uploaded = 1 WHERE image_id = \"imageId\"";

        for (String imageId : imageIdList) {
            String sql = "UPDATE " + SqliteConstant.TABLE_RDD_IMAGES + " SET " +
                    SqliteConstant.IS_IMAGE_UPLOADED + " = 1"
                    + " WHERE " + SqliteConstant.IMAGE_ID + " = \"" + imageId + "\""; // 1 or 1 = 1
            db.execSQL(sql);
        }
        LogUtils.d("更新 10条数据 is_image_uploaded 成功");
    }

    /**
     * 根据 imageId 将数据库中的相应数据的 isUploaded 属性改为1(表示已上传)
     * @param db 数据库对象
     * @param imageId imageId
     */
    public static void updateIsImageUploaded(SQLiteDatabase db, String imageId) {
        String sql = "UPDATE " + SqliteConstant.TABLE_RDD_IMAGES + " SET " +
                SqliteConstant.IS_IMAGE_UPLOADED + " = 1"
                + " WHERE " + SqliteConstant.IMAGE_ID + " = \"" + imageId + "\""; // 1 or 1 = 1
        db.execSQL(sql);
        LogUtils.d("更新 1条数据 is_image_uploaded 成功");
    }

    public static void insertImage(SQLiteDatabase db, Context context, String imageId, Bitmap bitmap,
                                   double angle, double width, double height, double longitude,
                                   double latitude, long creationDate, long lastUpdateTime,
                                   String street, String address) {

        DisplayMetrics dm = context.getResources().getDisplayMetrics();
        int dpiWidth = dm.widthPixels;
        int dpiHeight = dm.heightPixels;

        //经度为:113.954402
        //维度为:22.531808

        insertImage(db, imageId, bitmap, angle, width, height, dpiWidth, dpiHeight,
                SqliteConstant.GD_MAP, longitude, latitude, 0, 1, creationDate,
                1, lastUpdateTime, street, address);
    }

    /**
     * 保存图片
     *
     * @param db             数据库对象
     * @param imageId        图片ID  使用UUID
     * @param bitmap         位图
     * @param angle          图片的旋转角度
     * @param width          图片的宽度
     * @param height         图片的高度
     * @param dpiWidth       设备的分辨率宽度
     * @param dpiHeight      设备的分辨率高度
     * @param geoMap         地图提供者
     * @param longitude      经度
     * @param latitude       纬度
     * @param altitude       海拔
     * @param createdBy      创建者
     * @param creationDate   创建时间
     * @param lastUpdateBy   最近更新者
     * @param lastUpdateDate 最近更新时间
     * @param street         图片的街道信息
     * @param address        图片的详细地址信息
     */
    private static void insertImage(SQLiteDatabase db, String imageId, Bitmap bitmap,
                                    double angle, double width, double height, double dpiWidth,
                                    double dpiHeight, String geoMap, double longitude, double latitude,
                                    double altitude, int createdBy, long creationDate, int lastUpdateBy,
                                    long lastUpdateDate, String street, String address) {
        ContentValues contentValues = new ContentValues();
        contentValues.put(SqliteConstant.IMAGE_ID, imageId);
        contentValues.put(SqliteConstant.IMAGE, BitmapUtils.bitmapToBytes(bitmap));//图片转为二进制
        contentValues.put(SqliteConstant.ANGLE, angle);
        contentValues.put(SqliteConstant.WIDTH, width);
        contentValues.put(SqliteConstant.HEIGHT, height);
        contentValues.put(SqliteConstant.DPI_WIDTH, dpiWidth);
        contentValues.put(SqliteConstant.DPI_HEIGHT, dpiHeight);
        contentValues.put(SqliteConstant.GEO_MAP_INFO, geoMap);
        contentValues.put(SqliteConstant.LONGITUDE, longitude);
        contentValues.put(SqliteConstant.LATITUDE, latitude);
        contentValues.put(SqliteConstant.ALTITUDE, altitude);
        contentValues.put(SqliteConstant.CREATED_BY, createdBy);
        contentValues.put(SqliteConstant.CREATION_DATE, creationDate);
        contentValues.put(SqliteConstant.LAST_UPDATED_BY, lastUpdateBy);
        contentValues.put(SqliteConstant.LAST_UPDATED_DATE, lastUpdateDate);
        contentValues.put(SqliteConstant.STREET, street);
        contentValues.put(SqliteConstant.ADDRESS, address);
        // 默认设置为0(未上传)
        contentValues.put(SqliteConstant.IS_IMAGE_UPLOADED, 0);
        contentValues.put(SqliteConstant.CAPTURE_TIME, creationDate);

//        LogUtils.e("imageId: " + imageId);
//        LogUtils.e("image: " + Arrays.toString(BitmapUtils.bitmapToBytes(bitmap)));
        db.insert(SqliteConstant.TABLE_RDD_IMAGES, null, contentValues);

    }


    /**
     * 保存 图片病害识别框信息
     *
     * @param db                数据库对象
     * @param damageId          病害ID 主键
     * @param imageId           图片ID
     * @param damageCode        病害code值 拼音所写字符串
     * @param confident         概率
     * @param left              矩形框左侧的X坐标
     * @param top               矩形框上侧的Y坐标
     * @param right             矩形框右侧的X坐标
     * @param bottom            矩形框下侧的Y坐标
     * @param damageCaptureTime 病害采集时间
     */
    public static void insertRddImageDamages(SQLiteDatabase db, String damageId,
                                             String imageId, String damageCode, float confident,
                                             float left, float top, float right, float bottom,
                                             long damageCaptureTime) {
        ContentValues contentValues = new ContentValues();
        contentValues.put(SqliteConstant.DAMAGE_ID, damageId);
        contentValues.put(SqliteConstant.IMAGE_ID, imageId);
        contentValues.put(SqliteConstant.DAMAGE_CODE, damageCode);
        contentValues.put(SqliteConstant.CONFIDENT, confident);
        contentValues.put(SqliteConstant.DAMAGE_LEFT, left);
        contentValues.put(SqliteConstant.DAMAGE_TOP, top);
        contentValues.put(SqliteConstant.DAMAGE_RIGHT, right);
        contentValues.put(SqliteConstant.DAMAGE_BOTTOM, bottom);
        // 默认设置为0(未上传)
        contentValues.put(SqliteConstant.IS_DAMAGE_UPLOADED, 0);
        contentValues.put(SqliteConstant.DAMAGE_CAPTURE_TIME, damageCaptureTime);

        db.insert(SqliteConstant.TABLE_RDD_IMAGE_DAMAGES, null, contentValues);
    }

    /**
     * 从表 rdd_image_damages 中根据 damageId 删除数据
     */
    public static void deleteFromRddImageDamages(SQLiteDatabase db, String damageId) {
        String delSql = "DELETE FROM " + SqliteConstant.TABLE_RDD_IMAGE_DAMAGES +
                " WHERE " + SqliteConstant.DAMAGE_ID + " = \"" + damageId + "\"";
        db.execSQL(delSql);
        LogUtils.d("deleteFromRddImageDamages 删除成功");
    }

    /**
     * 从表 rdd_images 中根据 imageId 删除数据
     */
    public static void deleteFromRddImage(SQLiteDatabase db, String imageId) {
        String delSql = "DELETE FROM " + SqliteConstant.TABLE_RDD_IMAGES +
                " WHERE " + SqliteConstant.IMAGE_ID + " = \"" + imageId + "\"";
        db.execSQL(delSql);
        LogUtils.e("deleteFromRddImage");
    }


    /**
     * 将查询得到的cursor对象转换为list集合
     *
     * @param cursor 游标对象
     * @return person列表
     */
//    public static List<RddImage> cursorToListRddImages(Cursor cursor) {
//        List<RddImage> list = new ArrayList<>();
//        //moveToNext   如果返回true表示下一记录存在 否则表示游标中数据读取完毕
//        while (cursor.moveToNext()) {
//
//            String imageId = cursor.getString(cursor.getColumnIndex(SqliteConstant.IMAGE_ID));
//            byte[] imageData = cursor.getBlob(cursor.getColumnIndex(SqliteConstant.IMAGE));
//            double angle = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.ANGLE));
//            double width = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.WIDTH));
//            double height = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.HEIGHT));
//            double dpiWidth = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.DPI_WIDTH));
//            double dpiHeight = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.DPI_HEIGHT));
//            String geoMapInfo = cursor.getString(cursor.getColumnIndex(SqliteConstant.GEO_MAP_INFO));
//            double longitude = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.LONGITUDE));
//            double latitude = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.LATITUDE));
//            double altitude = cursor.getDouble(cursor.getColumnIndex(SqliteConstant.ALTITUDE));
//            int createdBy = cursor.getInt(cursor.getColumnIndex(SqliteConstant.CREATED_BY));
//            String creationTime = cursor.getString(cursor.getColumnIndex(SqliteConstant.CREATION_TIME));
//            int lastUpdatedBy = cursor.getInt(cursor.getColumnIndex(SqliteConstant.LAST_UPDATED_BY));
//            String lastUpdatedTime = cursor.getString(cursor.getColumnIndex(SqliteConstant.LATITUDE));
//            String street = cursor.getString(cursor.getColumnIndex(SqliteConstant.STREET));
//            String address = cursor.getString(cursor.getColumnIndex(SqliteConstant.ADDRESS));
//
//            RddImage bean = new RddImage(imageId, imageData, angle, width, height,
//                    dpiWidth, dpiHeight, geoMapInfo, longitude, latitude, altitude, createdBy,
//                    creationTime, lastUpdatedBy, lastUpdatedTime, street, address);
//            list.add(bean);
//        }
//        return list;
//    }

    /**
     * 将查询得到的cursor对象转换为list集合
     *
     * @param cursor 游标对象
     * @return person列表
     */
//    public static List<String> cursorToListString(Cursor cursor) {
//        List<String> list = new ArrayList<>();
//        //moveToNext   如果返回true表示下一记录存在 否则表示游标中数据读取完毕
//        while (cursor.moveToNext()) {
//            String imageId = cursor.getString(cursor.getColumnIndex(SqliteConstant.IMAGE_ID));
//            list.add(imageId);
//        }
//        return list;
//    }

    /**
     * 读取图片
     *
     * @param db 数据库对象
     * @return byte数组
     */
//    public static byte[] readImage(SQLiteDatabase db, String selection) {
//        byte[] imgData = null;
//
//        /**
//         * public Cursor query(String table, String[] columns, String selection,
//         *      String[] selectionArgs, String groupBy, String having,
//         *      String orderBy)
//         *
//         *   String table 表示查询的表名
//         *   String[] columns  表示查询表中的字段名称 null 查询所有
//         *   String selection  表示查询条件 where子句
//         *   String[] selectionArgs 表示查询条件占位符的取值
//         *   String groupBy 表示分组条件 group by 子句
//         *   String having  表示筛选条件 having 子句
//         *   String orderBy  表示排序条件 order by 子句
//         */
//        Cursor cursor = db.query(SqliteConstant.TABLE_RDD_IMAGES, new String[]{SqliteConstant.IMAGE_ID, SqliteConstant.IMAGE},
//                selection, null, null, null, null);
//        if (cursor.moveToNext()) {
//            //将Blob数据转化为字节数组
//            imgData = cursor.getBlob(cursor.getColumnIndex(SqliteConstant.IMAGE));
//            String imageId = cursor.getString(cursor.getColumnIndex(SqliteConstant.IMAGE_ID));
            LogUtils.e(imageId);
//        }
//
//        cursor.close();
//        return imgData;
//    }


}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值