日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

arcgis离线地图Java_ArcGIS API For Android离线地图的实现

發布時間:2023/12/20 Android 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 arcgis离线地图Java_ArcGIS API For Android离线地图的实现 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

今天搞了一個ArcGIS API For Android離線地圖的實現。

效果如下:

Android的版本是2.1

main.xml,這里要說明的,初始化范圍一定要有,不然會不能顯示的。

xmlns:android="http://schemas.android.com/apk/res/android"

android:id="@+id/map" android:layout_width="fill_parent"

android:layout_height="fill_parent"

initExtent="120.64101459999999 31.280566089 120.6769494 31.303135911">

AgsLOD.java

package com.esri.arcgis.sample;

import com.esri.core.internal.d.c;

public class AgsLOD extends c {

private static final long serialVersionUID = 4341699179151728883L;

private int level;

private double resolution;

private double scale;

public AgsLOD(int level, double scale, double resolution) {

super();

this.level = level;

this.scale = scale;

this.resolution = resolution;

}

public int a() {

return this.level;

}

public double b() {

return this.resolution;

}

public double c() {

return this.scale;

}

}

AgsOfflineTiledLayer.java

package com.esri.arcgis.sample;

import java.io.File;

import java.util.ArrayList;

import javax.xml.parsers.DocumentBuilder;

import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;

import org.w3c.dom.Node;

import org.w3c.dom.NodeList;

import android.content.Context;

import android.util.AttributeSet;

import android.util.Log;

import com.esri.android.map.TiledLayer;

import com.esri.core.geometry.Envelope;

import com.esri.core.geometry.Point;

import com.esri.core.geometry.SpatialReference;

import com.esri.core.internal.d.c;

import com.esri.core.internal.d.k;

import com.esri.core.map.TiledLayerModel;

public class AgsOfflineTiledLayer extends TiledLayer {

//瓦片文件的路徑呀

private String location = "/sdcard/BaseMap/Layers";

//REST里面的空間參考

private SpatialReference spatialReference = SpatialReference.create(4326);

//全圖范圍

private Envelope fullExtent = new Envelope(120.64101459999999,

31.280566089, 120.6769494, 31.303135911);

private k tileInfo;

public AgsOfflineTiledLayer(Context context, AttributeSet attrs) {

super(context, attrs);

try {

init();

} catch (Exception ex) {

ex.printStackTrace();

}

}

@Override

protected TiledLayerModel initModel() throws Exception {

return new AgsOfflineTiledLayerModel(location, spatialReference, fullExtent, tileInfo);

}

private void init() {

String confPath = location + File.separator + "conf.xml";

Log.i("conf", confPath);

try {

tileInfo = new k();

DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory

.newInstance();

DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();

File file = new File(confPath);

Document doc = docBuilder.parse(file);

NodeList nsX = doc.getElementsByTagName("X");

double originX = Double.valueOf(nsX.item(0).getFirstChild()

.getNodeValue());

NodeList nsY = doc.getElementsByTagName("Y");

double originY = Double.valueOf(nsY.item(0).getFirstChild()

.getNodeValue());

tileInfo.f = new Point(originX, originY);

NodeList nsTileRows = doc.getElementsByTagName("TileRows");

tileInfo.a = Integer.valueOf(nsTileRows.item(0).getFirstChild()

.getNodeValue());

NodeList nsTileCols = doc.getElementsByTagName("TileCols");

tileInfo.b = Integer.valueOf(nsTileCols.item(0).getFirstChild()

.getNodeValue());

NodeList nsLODInfos = doc.getElementsByTagName("LODInfos");

tileInfo.h = new ArrayList();

NodeList lodInfos = nsLODInfos.item(0).getChildNodes();

for (int j = 0, jcount = lodInfos.getLength(); j < jcount; j++) {

Node lod = lodInfos.item(j);

NodeList list = lod.getChildNodes();

int level = Integer.valueOf(list.item(0).getFirstChild()

.getNodeValue());

double scale = Double.valueOf(list.item(1).getFirstChild()

.getNodeValue());

double resolution = Double.valueOf(list.item(2).getFirstChild()

.getNodeValue());

tileInfo.h.add(new AgsLOD(level, scale, resolution));

}

} catch (Exception e) {

e.printStackTrace();

}

}

}

AgsOfflineTiledLayerModel.java

package com.esri.arcgis.sample;

import java.io.File;

import java.io.FileInputStream;

import android.util.Log;

import com.esri.core.geometry.Envelope;

import com.esri.core.geometry.SpatialReference;

import com.esri.core.internal.d.k;

import com.esri.core.map.TiledLayerModel;

public class AgsOfflineTiledLayerModel extends TiledLayerModel {

private static final long serialVersionUID = 7726567118839553087L;

private String location;

public AgsOfflineTiledLayerModel(String location, SpatialReference sr,

Envelope full, k tileInfo) {

super(sr, full, tileInfo);

this.location = location;

}

@Override

public byte[] getTile(int level, int row, int col) throws Exception {

byte[] result = null;

try {

String bundlesDir = location + File.separator + "_alllayers";

Log.i("location", bundlesDir);

String l = "0" + level;

int lLength = l.length();

if (lLength > 2) {

l = l.substring(lLength - 2);

}

l = "L" + l;

int rGroup = 128 * (row / 128);

String r = "000" + Integer.toHexString(rGroup);

int rLength = r.length();

if (rLength > 4) {

r = r.substring(rLength - 4);

}

r = "R" + r;

int cGroup = 128 * (col / 128);

String c = "000" + Integer.toHexString(cGroup);

int cLength = c.length();

if (cLength > 4) {

c = c.substring(cLength - 4);

}

c = "C" + c;

String bundleBase = String

.format("%s/%s/%s%s", bundlesDir, l, r, c);

String bundlxFileName = bundleBase + ".bundlx";

String bundleFileName = bundleBase + ".bundle";

int index = 128 * (col - cGroup) + (row - rGroup);

FileInputStream isBundlx = new FileInputStream(bundlxFileName);

isBundlx.skip(16 + 5 * index);

byte[] buffer = new byte[5];

isBundlx.read(buffer);

long offset = (long) (buffer[0] & 0xff) + (long) (buffer[1] & 0xff)

* 256 + (long) (buffer[2] & 0xff) * 65536

+ (long) (buffer[3] & 0xff) * 16777216

+ (long) (buffer[4] & 0xff) * 4294967296L;

FileInputStream isBundle = new FileInputStream(bundleFileName);

isBundle.skip(offset);

byte[] lengthBytes = new byte[4];

isBundle.read(lengthBytes);

int length = (int) (lengthBytes[0] & 0xff)

+ (int) (lengthBytes[1] & 0xff) * 256

+ (int) (lengthBytes[2] & 0xff) * 65536

+ (int) (lengthBytes[3] & 0xff) * 16777216;

result = new byte[length];

isBundle.read(result);

} catch (Exception ex) {

ex.printStackTrace();

}

return result;

}

}

AgsOfflineTiles.java

package com.esri.arcgis.sample;

import com.esri.android.map.MapView;

import android.app.Activity;

import android.os.Bundle;

public class AgsOfflineTiles extends Activity {

MapView map = null;

AgsOfflineTiledLayer layer = null;

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

map = (MapView) findViewById(R.id.map);

layer = (AgsOfflineTiledLayer) findViewById(R.id.layer);

}

}

在SD卡的瓦片數據的路徑

源碼和測試數據在附件中

大小: 44.4 KB

BaseMap.rar (1.5 MB)

下載次數: 395

AgsOfflineTiles.rar (2.4 MB)

下載次數: 381

大小: 36.8 KB

查看圖片附件

總結

以上是生活随笔為你收集整理的arcgis离线地图Java_ArcGIS API For Android离线地图的实现的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 日韩尤物 | 午夜影院h| 中文字幕在线观看视频一区二区 | 风间由美一区二区 | 成年人看的黄色片 | www.亚洲成人 | 国产成人精品一区二区三区免费 | 三区在线观看 | av中文在线播放 | 播放灌醉水嫩大学生国内精品 | 日本午夜激情 | 亚洲熟妇无码一区二区三区导航 | 国产在线视视频有精品 | www.九九九 | 国产91丝袜在线观看 | 欧美一级做a爰片免费视频 成人激情在线观看 | 久久99精品久久久久久三级 | 午夜网 | 免费不卡av | 玖草视频在线观看 | 亚洲欧美中文日韩在线 | 无码国产精品一区二区免费式直播 | 国产一区二区久久久 | 一区二区在线免费 | 成人无高清96免费 | 神马电影久久 | 黄色片在线看 | 性渴老太作爱 | 久久久无码人妻精品无码 | 欧洲久久久| 18在线观看视频 | 性欧美www| 国产chinesehd精品露脸 | 一级视频片| 久久久亚洲av波多野结衣 | 亚洲精品wwww| 中国新婚夫妻性猛交 | 久久色图 | 在线日韩亚洲 | 九一av| а√天堂资源官网在线资源 | 日本亚洲黄色 | 久久久久久九九九 | 99精品视频免费看 | 欧美日韩一区二区视频在线观看 | 久久久久久黄色 | 日本免费一区二区三区视频 | 美足av电影 | 午夜福利啪啪片 | 久久香蕉综合 | 国产精品四虎 | 黄色国产视频网站 | 成人在线观看免费 | 99热18| 裸体裸乳被免费看视频 | 91精品国产日韩91久久久久久 | 久久精品这里只有精品 | av资源共享| 男人的天堂avav | 波多野结衣av无码 | 不卡中文字幕av | 专干中国老太婆hd | 天天爽影院 | 男女性生活视频网站 | 国产一区 在线播放 | 精品美女一区二区 | 中文字幕22页 | 中文在线中文资源 | 大咪咪av| 淫羞阁av导航| 国产二区精品视频 | 国产综合精品在线 | jizzjizzjizz亚洲女| 日本国产一级片 | 欧美三级视频网站 | 男人的天堂免费 | 成人毛片网站 | www.日本免费| 成人午夜在线视频 | 精品无码一区二区三区在线 | 香蕉日日 | 三极片黄色 | 日韩一区在线看 | 久久午夜免费视频 | 在线观看成人黄色 | 日本a在线播放 | 一级黄色美女 | 亚洲一区二区三区日韩 | 男人添女人下部高潮全视频 | 亚洲欧美日韩色图 | 99色网站 | 老熟妇一区二区 | 国产一区二区三区免费播放 | 冲田杏梨 在线 | 日韩精品久久久久久久 | 国产精品久久久久久久久久久久久久久 | 97国产精品 | 免费在线观看av网址 | 午夜黄色网 |