多点移动电子地图定位

本文章属于项目资料整理,所用资源均来源于网络

需求分析及技术调研

项目描述

  • 因公司业务需要开发一款应用在体育赛事指挥调度的软件,用来在地图上定位现场的摄像师实时的位置,和计算摄像师到地图中标定的沿途关键点的路程。

模块划分

  • 根据项目描述,需要一个实时采集摄像师的软件,暂且叫做手机位置发射端。需要一个平板地图显示接收端。而中间需要一个服务器端作为转发器,最终采用方案3作为项目实施方案。

关于转发服务器的解决方案

  1. 直接用socket通信,平板接收端当作Socket服务器,手机当作Socket客户端。后来发现在公网中IP地址总是变化的后来也就放弃这个方案了。
  2. 用公司服务器开发人员做一个Socket服务器。这个方案被我否绝了,原因是自己做一个Socket服务器没有什么经验,而且需要一个公网ip。
  3. 采用百度鹰眼传输位置信息。这样一来,平板接收端的SDK体系更加紧凑。因为接收端的地图显示用百度地图,数据传输也是用百度的产品百度鹰眼。
  4. 采用环信即时通信模块中的点对点聊天功能,可以把位置实时传给平板接收端。据官网上说这个消耗流量很小。但是后来我感觉能用一家的服务都用一家的服务就行了,万一以后环信的服务和百度地图有冲突了不好解决。

关于定位的一些网络资源

全球四大卫星定位系统

手机常用的定位技术

被纠偏的国内电子地图

  • 百度地图
    之前并没有注意到百度地图上的经纬度坐标点是经过纠偏算法之后的地图,导致最近在做一个关于定位系统软件的时候遇到了些麻烦,我利用Android自带的获取地理经纬度的方法获取到真实的经纬度坐标并把坐标点放在地图上时并没有注意定位点已经偏离了一条街的距离(因为当时两条街挨着很近,而且都是在马路左侧所以当时大意了)。
    下面是网上一些解释
    gps纠偏及大陆地图偏移原因:http://yanue.net/post-121.html
    为何您的坐标不准?如何纠偏? :http://www.cnblogs.com/milkmap/p/3627940.html
    百度定位SDK:http://lbsyun.baidu.com/index.php?title=android-locsdk/qa

GPS定位基本原理

手机位置发射端代码

  • 功能说明:屏幕上显示经纬度坐标值且需要不断的上报GPS数据到百度服务器,并自定义控件实现GPS卫星信号强度。
    这里写图片描述

xml布局
采用GridLayout实现上半部分的属性和属性值的布局。
底部SNR柱形图采用View绘制而成

<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:columnCount="2"
    android:columnOrderPreserved="true"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:padding="8dp"
    android:rowOrderPreserved="true"
    android:useDefaultMargins="true"
    tools:context=".EagleLaunchActivity" >

    <TextView
        style="@style/gps_launch"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:text="设备ID:" />

    <TextView
        android:id="@+id/device_id"
        style="@style/gps_launch"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="fill" />

    <TextView
        style="@style/gps_launch"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:text="GPS状态:" />

    <TextView
        android:id="@+id/gps_state"
        style="@style/gps_launch"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="fill" />

    <TextView
        style="@style/gps_launch"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:text="定位精度:" />

    <TextView
        android:id="@+id/accuracy"
        style="@style/gps_launch"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="fill" />

    <TextView
        style="@style/gps_launch"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:text="当前速度:" />

    <TextView
        android:id="@+id/speed"
        style="@style/gps_launch"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="fill" />

    <TextView
        style="@style/gps_launch"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:text="GPS经度:" />

    <TextView
        android:id="@+id/longitude"
        style="@style/gps_launch"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="fill" />

    <TextView
        style="@style/gps_launch"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:text="GPS纬度:" />

    <TextView
        android:id="@+id/latitude"
        style="@style/gps_launch"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="fill" />

    <TextView
        style="@style/gps_launch"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:text="GPS海拔:" />

    <TextView
        android:id="@+id/altitude"
        style="@style/gps_launch"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="fill" />

    <xxx.xxxx.eaglemap_launch.DrawView
        android:id="@+id/drawView"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_columnSpan="2"
        android:layout_gravity="fill"
        android:background="#aabbccdd" >

        <TextView
            android:id="@+id/find_fix"
            style="@style/gps_launch"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:text="SNR柱形图" />
    </xxx.xxxx.eaglemap_launch.DrawView>

</GridLayout>

Java代码如下,采用setData()方法赋值。

package xxx.xxxx.eaglemap_launch;

import java.util.ArrayList;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.util.AttributeSet;
import android.widget.RelativeLayout;

public class DrawView extends RelativeLayout {

    private ArrayList<Satellite> list;
    private final int maxSate = 24;//最大卫星数量
    private final int unit = 70;//SNR信号最大值
    private final int gap = 3;//柱子间隙
    private float textSize = 30;//文字大小
    private final int threshold30 = 30;
    private final int threshold40 = 40;
    private final int textSpace = 50;//预留的标题文字空间

    private void init() {
        textSize = getResources().getDimension(R.dimen.DrawViewTextSize);
    }

    public DrawView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public DrawView(Context context) {
        super(context);
        init();
    }

    public void setData(ArrayList<Satellite> list) {
        this.list = list;
        invalidate();//将会调用onDraw方法,触发重绘
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        Paint p = new Paint(Paint.FAKE_BOLD_TEXT_FLAG);
        p.setColor(Color.BLACK);
        p.setTextSize(textSize);
        p.setTextAlign(Align.CENTER);
        p.setStyle(Paint.Style.FILL);// 设置填满

        int width = canvas.getWidth();
        int bottom = canvas.getHeight();

        if (list == null) {
            return;
        }
        int length = list.size();
        for (int i = 0; i < length; i++) {
            Satellite s = list.get(i);
            int d = (int) s.snr;
            int top = bottom - (bottom - textSpace) / unit * d;
            int left = width / maxSate * i;
            int right = width / maxSate * (i + 1) - gap;

            p.setColor(Color.BLACK);
            canvas.drawText(d + "", left + (right - left) / 2, top, p);
            if(d >= threshold40 && s.usedInFix) {
                p.setColor(Color.GREEN);
            } else if (d >= threshold30 && s.usedInFix) {
                p.setColor(Color.YELLOW);
            } else if (s.usedInFix) {
                p.setColor(Color.RED);
            } else {
                p.setColor(Color.GRAY);
            }
            canvas.drawRect(left, top, right, bottom, p);
        }
    }
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值