首页 文章 精选 留言 我的

精选列表

搜索[服务],共10000篇文章
优秀的个人博客,低调大师

JPower v2.0.1 发布,微服务快速开发平台

JPower v2.0.1 已经发布.Jpower是一款由政务商业项目升级优化而成的SpringCloud框架,采用Java8API实现了业务代码,集成SpringCloud Alibaba全套组件等核心技术,可用于快速搭建企业级的系统平台。 此版本更新内容包括: up avue 2.8.12-alpha add beautiful 主题 登录逻辑微调 auth得SecureUtil优化 redis得CacheUtil优化 swagger注入方式优化 客户端拦截方式增强,支持一个接口对应多个客户端 动态路由重新实现 add LICENSE 详情查看:https://gitee.com/gdzWork/JPower/releases/v2.0.1

优秀的个人博客,低调大师

腾讯位置服务GPS轨迹录制-安卓篇

前言 在地图的使用中,尤其在导航场景下,进行GPS轨迹录制是十分必要并且有用的,本文会对于安卓系统下的轨迹录制部分做一个分享。 系统架构 对于一个GPSRecordSystem(GPS轨迹录制系统)主要分成3个部分:开始录制,录制GPS定位,结束录制并存储,如上图右方所示。在实际应用中,以导航系统为例:(1)在开始导航时(start navi),进行录制工作的相关配置;(2)收到安卓系统的onLocationChanged的callback进行GPSLocation的记录;(3)结束导航(stop navi)时,停止记录并存入文件。 相关代码展示 用到的相关变量 private LocationManager mLocationManager; // 系统locationManager private LocationListener mLocationListener; // 系统locationListener private boolean mIsRecording = false; // 是否正在录制 private List<String> mGpsList; // 记录gps的list private String mRecordFileName; // gps文件名称 开始录制 开始录制一般是在整个系统工作之初,比如在导航场景下,当“开始导航”时,可以开始进行“startRecordLocation” 的配置 public void startRecordLocation(Context context, String fileName) { // 已经在录制中不进行录制 if (mIsRecording) { return; } Toast.makeText(context, "start record location...", Toast.LENGTH_SHORT).show(); // 初始化locationManager和locationListener mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); mLocationListener = new MyLocationListener(); try { // 添加listener mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, mLocationListener); } catch (SecurityException e) { Toast.makeText(context, "start record location error!!!", Toast.LENGTH_SHORT).show(); Log.e(TAG, "startRecordLocation Exception", e); e.printStackTrace(); } // 记录文件名称,笔者这里使用“realLocationRecord + routeID”形式进行记录 mRecordFileName = fileName; if (!mRecordFileName.endsWith(".gps")) { mRecordFileName += ".gps"; } mIsRecording = true; } 录制中记录轨迹 记录location一般是在获取安卓系统onLocationChanged回调时调用“recordGPSLocation” public void recordGPSLocation(Location location) { if (mIsRecording && location != null) { // 记录location to list mGpsList.add(locationToString(location)); } } locationToString工具方法 驱动导航工作的GPS轨迹点一般要包含以下几个要素,经度,纬度,精度,角度,速度,时间,海拔高度,所以在此记录下,为后期轨迹回放做准备。 private String locationToString(Location location) { StringBuilder sb = new StringBuilder(); long time = System.currentTimeMillis(); String timeStr = gpsDataFormatter.format(new Date(time)); sb.append(location.getLatitude()); sb.append(","); sb.append(location.getLongitude()); sb.append(","); sb.append(location.getAccuracy()); sb.append(","); sb.append(location.getBearing()); sb.append(","); sb.append(location.getSpeed()); sb.append(","); sb.append(timeStr); sb.append(","); sb.append(df.format((double) time / 1000.0)); // sb.append(df.format(System.currentTimeMillis()/1000.0)); // sb.append(df.format(location.getTime()/1000.0)); sb.append(","); sb.append(location.getAltitude()); sb.append("\n"); return sb.toString(); } 结束录制并保存gps文件 结束录制一般作用在整个系统的结尾,例如在导航场景下,“结束导航”时停止录制调用“stopRecordLocation” public void stopRecordLocation(Context context) { Toast.makeText(context, "stop record location, save to file...", Toast.LENGTH_SHORT).show(); // 移除listener mLocationManager.removeUpdates(mLocationListener); String storagePath = StorageUtil.getStoragePath(context); // 存储的路径 String filePath = storagePath + mRecordFileName; saveGPS(filePath); mIsRecording = false; } GPS轨迹存储工具方法 private void saveGPS(String path) { OutputStreamWriter writer = null; try { File outFile = new File(path); File parent = outFile.getParentFile(); if (parent != null && !parent.exists()) { parent.mkdirs(); } OutputStream out = new FileOutputStream(outFile); writer = new OutputStreamWriter(out); for (String line : mGpsList) { writer.write(line); } } catch (Exception e) { Log.e(TAG, "saveGPS Exception", e); e.printStackTrace(); } finally { if (writer != null) { try { writer.flush(); } catch (IOException e) { e.printStackTrace(); Log.e(TAG, "Failed to flush output stream", e); } try { writer.close(); } catch (IOException e) { e.printStackTrace(); Log.e(TAG, "Failed to close output stream", e); } } } } StorageUtil的getStoragePath工具方法 // 存储在跟路径下/TencentMapSDK/navigation private static final String NAVIGATION_PATH = "/tencentmapsdk/navigation"; // getStoragePath工具方法 public static String getStoragePath(Context context) { if (context == null) { return null; } String strFolder; boolean hasSdcard; try { hasSdcard = Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED); } catch (Exception e) { Log.e(TAG, "getStoragePath Exception", e); e.printStackTrace(); hasSdcard = false; } if (!hasSdcard) { strFolder = context.getFilesDir().getPath() + NAVIGATION_PATH; File file = new File(strFolder); if (!file.exists()) { file.mkdirs(); } } else { strFolder = Environment.getExternalStorageDirectory().getPath() + NAVIGATION_PATH; File file = new File(strFolder); if (!file.exists()) { // 目录不存在,创建目录 if (!file.mkdirs()) { strFolder = context.getFilesDir().getPath() + NAVIGATION_PATH; file = new File(strFolder); if (!file.exists()) { file.mkdirs(); } } } else { // 目录存在,创建文件测试是否有权限 try { String newFile = strFolder + "/.test"; File tmpFile = new File(newFile); if (tmpFile.createNewFile()) { tmpFile.delete(); } } catch (IOException e) { e.printStackTrace(); Log.e(TAG, "getStoragePath Exception", e); strFolder = context.getFilesDir().getPath() + NAVIGATION_PATH; file = new File(strFolder); if (!file.exists()) { file.mkdirs(); } } } } return strFolder; } 结果展示 最终存储在了手机目录下的navigation目录 后续工作 后续可以对于录制的gps文件讲解在导航场景下进行轨迹回放的分享

资源下载

更多资源
腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册