Maps,Geocoding,and Location-Based Services

本文深入探讨了如何获取特定的定位提供者实例,并详细介绍了查找可用定位提供者的方法,包括使用Criteria筛选最佳定位提供者。同时,文章还涵盖了如何找到当前位置、跟踪移动、进行逆地理编码和正地理编码等关键功能。

SELECTING A LOCATION PROVIDER

To get an instance of a specific provider, call getProvider, passing in the name:
String providerName = LocationManager.GPS_PROVIDER;
LocationProvider gpsProvider;
gpsProvider = locationManager.getProvider(providerName);

 

Finding the Available Providers

The LocationManager class includes static string constants that return the provider name for the two
most common Location Providers:
➤ LocationManager.GPS_PROVIDER
➤ LocationManager.NETWORK_PROVIDER
To get a list of names for all the providers available on the device, call getProviders, using a Boolean
to indicate if you want all, or only the enabled, providers to be returned:
boolean enabledOnly = true;
List<String> providers = locationManager.getProviders(enabledOnly);

 

Finding Location Providers Using Criteria

Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_COARSE);
criteria.setPowerRequirement(Criteria.POWER_LOW);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setSpeedRequired(false);
criteria.setCostAllowed(true);

 

String bestProvider = locationManager.getBestProvider(criteria, true);

 

If more than one Location Provider matches your criteria, the one with the greatest accuracy is returned.
If no Location Providers meet your requirements the criteria are loosened, in the following order, until
a provider is found:
➤ Power use
➤ Accuracy
➤ Ability to return bearing, speed, and altitude

 

FINDING YOUR LOCATION

String serviceString = Context.LOCATION_SERVICE;
LocationManager locationManager;
locationManager = (LocationManager)getSystemService(serviceString);

 

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

 

String provider = LocationManager.GPS_PROVIDER;
Location location = locationManager.getLastKnownLocation(provider);

 

Tracking Movement

Use the requestLocationUpdates method to get updates whenever the current location changes, using
a LocationListener.

 

locationManager.requestLocationUpdates(provider, t, distance,
myLocationListener);

locationManager.removeUpdates(myLocationListener);

 

 Reverse Geocoding

 

location =
locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
double latitude = location.getLatitude();
double longitude = location.getLongitude();
List<Address> addresses = null;
Geocoder gc = new Geocoder(this, Locale.getDefault());
try {
addresses = gc.getFromLocation(latitude, longitude, 10);
} catch (IOException e) {}

 

 

Forward Geocoding 

List<Address> result = geocoder.getFromLocationName(aStreetAddress, maxResults);

Geocoder fwdGeocoder = new Geocoder(this, Locale.US);
String streetAddress = "160 Riverside Drive, New York, New York";
List<Address> locations = null;
try {
locations = fwdGeocoder.getFromLocationName(streetAddress, 10);
} catch (IOException e) {}

List<Address> locations = null;
try {
locations = fwdGeocoder.getFromLocationName(streetAddress, 10,
n, e, s, w);
} catch (IOException e) {}

 

 

 

Introducing Map View and Map Activity

MapView is theMap View control

 

MapActivity is the base class you extend to create a new Activity that can include a Map
View. The MapActivity class handles the application life cycle and background service
management required for displaying maps. As a result you can use Map Views only within
MapActivity-derived Activities.

 

Overlay is the class used to annotate your maps. Using Overlays, you can use a Canvas to
draw onto any number of layers that are displayed on top of a Map View.

 

MapController is used to control the map, enabling you to set the center location and zoom
levels.
➤ MyLocationOverlay is a special Overlay that can be used to display the current position and
orientation of the device.
➤ ItemizedOverlays and OverlayItems are used together to let you create a layer of map markers,
displayed using Drawables and associated text.

 

mapView.setSatellite(true);
mapView.setStreetView(true);
mapView.setTraffic(true);

 

int maxZoom = mapView.getMaxZoomLevel();
GeoPoint center = mapView.getMapCenter();
int latSpan = mapView.getLatitudeSpan();
int longSpan = mapView.getLongitudeSpan();

 

mapView.setBuiltInZoomControls(true);

 

Using the Map Controller

 

MapController mapController = myMapView.getController();

Double lat = 37.422006*1E6;
Double lng = -122.084095*1E6;
GeoPoint point = new GeoPoint(lat.intValue(), lng.intValue());

mapController.setCenter(point);
mapController.setZoom(1);

 

mapController.animateTo(point);

 

 

 

 

Creating and Using Overlays

import android.graphics.Canvas;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
public class MyOverlay extends Overlay {
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
if (shadow == false) {
[ . . . Draw annotations on main map layer . . . ]
}
else {
[ . . . Draw annotations on the shadow layer . . . ]
}
}
@Override
public boolean onTap(GeoPoint point, MapView mapView) {

// Return true if screen tap is handled by this overlay
return false;
}
}

 

Introducing Projections

Projection projection = mapView.getProjection();

Point myPoint = new Point();
// To screen coordinates
projection.toPixels(geoPoint, myPoint);
// To GeoPoint location coordinates
projection.fromPixels(myPoint.x, myPoint.y);

 

Drawing on the Overlay Canvas

@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
Projection projection = mapView.getProjection();
Double lat = -31.960906*1E6;
Double lng = 115.844822*1E6;
GeoPoint geoPoint = new GeoPoint(lat.intValue(), lng.intValue());
if (shadow == false) {
Point myPoint = new Point();
projection.toPixels(geoPoint, myPoint);
// Create and setup your paint brush
Paint paint = new Paint();
paint.setARGB(250, 255, 0, 0);
paint.setAntiAlias(true);
paint.setFakeBoldText(true);
// Create the circle
int rad = 5;
RectF oval = new RectF(myPoint.x-rad, myPoint.y-rad,
myPoint.x+rad, myPoint.y+rad);

 

// Draw on the canvas
canvas.drawOval(oval, paint);
canvas.drawText("Red Circle", myPoint.x+rad, myPoint.y, paint);
}
}

 

Handling Map Tap Events

The onTap handler receives two parameters:
➤ A GeoPoint that contains the latitude/longitude of the map location tapped
➤ The MapView that was tapped to trigger this event
When you are overriding onTap, the method should return true if it has handled a particular tap and
false to let another Overlay handle it

 

@Override
public boolean onTap(GeoPoint point, MapView mapView) {
// Perform hit test to see if this overlay is handling the click
if ([ . . . perform hit test . . . ]) {
[ . . . execute on tap functionality . . . ]
return true;
}

 

// If not handled return false
return false;
}

 

Adding and Removing Overlays

List<Overlay> overlays = mapView.getOverlays();

List<Overlay> overlays = mapView.getOverlays();
MyOverlay myOverlay = new MyOverlay();
overlays.add(myOverlay);
mapView.postInvalidate();

 

 

Creating a new Itemized Overlay

public class MyItemizedOverlay extends ItemizedOverlay<OverlayItem> {
public MyItemizedOverlay(Drawable defaultMarker) {
super(boundCenterBottom(defaultMarker));
populate();
}
@Override
protected OverlayItem createItem(int index) {
switch (index) {
case 1:
Double lat = 37.422006*1E6;
Double lng = -122.084095*1E6;
GeoPoint point = new GeoPoint(lat.intValue(), lng.intValue());
OverlayItem oi;
oi = new OverlayItem(point, "Marker", "Marker Text");
return oi;
}
return null;
}
@Override
public int size() {
// Return the number of markers in the collection
return 1;
}
}

 

 

List<Overlay> overlays = mapView.getOverlays();
MyItemizedOverlay markers = new
MyItemizedOverlay(r.getDrawable(R.drawable.marker));
overlays.add(markers);

 

Skeleton code for a dynamic Itemized Overlay

public class MyDynamicItemizedOverlay extends ItemizedOverlay<OverlayItem>
{
private ArrayList<OverlayItem> items;
public MyDynamicItemizedOverlay(Drawable defaultMarker) {
super(boundCenterBottom(defaultMarker));
items = new ArrayList<OverlayItem>();
populate();
}
public void addNewItem(GeoPoint location, String markerText,
String snippet) {
items.add(new OverlayItem(location, markerText, snippet));
populate();
}
public void removeItem(int index) {
items.remove(index);
populate();
}
@Override
protected OverlayItem createItem(int index) {
return items.get(index);
}
 

 

标题基于SpringBoot的学生读书笔记共享平台设计研究AI更换标题第1章引言介绍学生读书笔记共享平台的研究背景、意义、国内外研究现状、论文方法以及创新点。1.1研究背景与意义阐述学生读书笔记共享平台在当前教育环境下的重要性。1.2国内外研究现状分析国内外学生读书笔记共享平台的研究进展与现状。1.3研究方法及创新点概述本文的研究方法与平台设计的创新点。第2章相关理论总结和评述与SpringBoot及读书笔记共享平台相关的理论。2.1SpringBoot框架介绍阐述SpringBoot框架的特点、优势及其在Web开发中的应用。2.2读书笔记共享平台相关理论介绍读书笔记共享平台的设计原则、功能需求及用户体验理论。2.3数据库设计与优化理论简述数据库设计的基本原则及优化策略。第3章平台设计详细介绍基于SpringBoot的学生读书笔记共享平台的设计方案。3.1平台架构设计平台的整体架构,包括前端、后端及数据库的设计。3.2功能模块设计阐述平台的主要功能模块,如用户管理、笔记上传、笔记分享等。3.3数据库设计介绍数据库的设计方案,包括表结构、索引及关系设计。第4章平台实现详细描述平台的具体实现过程,包括技术选型、开发环境搭建等。4.1技术选型与开发环境介绍开发平台所采用的技术栈及开发环境配置。4.2关键代码实现展示平台实现过程中的关键代码片段,如用户登录、笔记上传等功能的实现。4.3平台测试与优化平台的测试过程及优化策略,确保平台的稳定性和性能。第5章平台应用与分析对平台的应用效果进行分析,包括用户反馈、使用数据等。5.1用户反馈收集与分析收集用户反馈,分析用户对平台的满意度及改进建议。5.2使用数据分析通过数据分析工具,分析平台的使用情况,如用户活跃度、笔记分享量等。5.3对比方法分析对比其他类似平台,分析本平台的优势与不足。第6章结论与展望总结本文的研究成果,并对未来研究方向
内容概要:本文针对多渗透率电动汽车接入对配电网的影响,开展承载能力评估研究,提出了一套融合多类型分布式资源的综合评估体系。研究构建了包含电动汽车、分布式光伏及静止无功补偿器(SVC)的配电网协同运行基础模型,建立了涵盖一次设备安全性、负荷平稳性、电能质量与系统运行效率的多维度评价指标体系,并采用熵权法与模糊综合评价相结合的双层模型实现指标客观赋权与系统承载能力的量化评分。通过Matlab仿真平台,系统分析了不同电动汽车渗透率下各项指标的演变规律与敏感性特征,揭示了高比例电动汽车接入对配电网的潜在压力,从而为电网的规划决策、扩容改造以及电动汽车的有序充电管理提供了科学、量化的技术支撑。; 适合人群:具备电力系统、电气工程或相关领域基础知识,从事新能源并网、智能配电网、电动汽车与电网互动(V2G)等方向研究的研究生、科研人员及电力系统工程技术人员。; 使用场景及目标:①评估大规模电动汽车无序或有序接入对配电网安全稳定运行的综合影响;②为配电网络的升级改造、设备选型及电动汽车充电基础设施布局提供决策依据;③学习并复现基于熵权-模糊综合评价法的多指标体系构建与量化评估方法,掌握其在复杂电力系统分析中的应用。; 阅读建议:建议结合文中提供的Matlab代码进行仿真复现,重点理解算例参数设置、多维指标体系的设计逻辑以及双层评价模型的具体实现步骤,通过调整渗透率等关键参数进行对比实验,以深化对评估方法原理与实际应用效果的理解。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值