1. 程式人生 > >【worldwind學習】worldwindjava新增google中國衛星圖切片圖層和糾偏

【worldwind學習】worldwindjava新增google中國衛星圖切片圖層和糾偏

1.worldwindjava新增谷歌衛星圖層

/*
 * Copyright (C) 2017 United States Government as represented by the Administrator of the
 * National Aeronautics and Space Administration.
 * All Rights Reserved.
 */

package gov.nasa.worldwind.layers.Earth;
 
import java.net.MalformedURLException;
import java.net.URL;
 
import gov.nasa.worldwind.avlist.AVKey;
import gov.nasa.worldwind.avlist.AVList;
import gov.nasa.worldwind.avlist.AVListImpl;
import gov.nasa.worldwind.geom.Angle;
import gov.nasa.worldwind.geom.LatLon;
import gov.nasa.worldwind.layers.mercator.BasicMercatorTiledImageLayer;
import gov.nasa.worldwind.layers.mercator.MercatorSector;
import gov.nasa.worldwind.util.LevelSet;
import gov.nasa.worldwind.util.Tile;
import gov.nasa.worldwind.util.TileUrlBuilder;
 
public class GoogleLayer extends BasicMercatorTiledImageLayer{
 
    public GoogleLayer() {
        super(makeLevels());
        // TODO Auto-generated constructor stub
    }
 
    private static LevelSet makeLevels() {
        // TODO Auto-generated method stub
        AVList params = new AVListImpl();
 
        params.setValue(AVKey.TILE_WIDTH, 256);
        params.setValue(AVKey.TILE_HEIGHT, 256);
        params.setValue(AVKey.DATA_CACHE_NAME, "Earth/GoogleMap");
        params.setValue(AVKey.DATASET_NAME, "*");
        params.setValue(AVKey.FORMAT_SUFFIX, ".jpg");
        params.setValue(AVKey.NUM_LEVELS, 16);
        params.setValue(AVKey.NUM_EMPTY_LEVELS, 0);
        params.setValue(AVKey.LEVEL_ZERO_TILE_DELTA, new LatLon(Angle
                .fromDegrees(22.5d), Angle.fromDegrees(45d)));
        params.setValue(AVKey.SECTOR, new MercatorSector(-1.0, 1.0,
                Angle.NEG180, Angle.POS180));
        params.setValue(AVKey.TILE_URL_BUILDER, new URLBuilder());
 
        return new LevelSet(params);
    }
    private static class URLBuilder implements TileUrlBuilder
    {
        public URL getURL(Tile tile, String imageFormat)
                throws MalformedURLException
        {
            String url=String.format(
                    "http://www.google.cn/maps/
[email protected]
&gl=cn&x=%s&y=%s&z=%s", tile.getColumn(), (1 << (tile.getLevelNumber()) + 3) - 1 - tile.getRow(), (tile.getLevelNumber() + 3) ); System.out.println(url); return new URL(url); } } @Override public String toString() { return "谷歌地圖影像"; } }

2.修改函式糾正偏移

修改computeTextureTransform函式

注意,這裡是臨時改法,只是作為驗證,至於具體應用中程式碼肯定不是這麼亂寫,因為還要考慮其他不需要偏移的圖層,還有這個偏移好像只有在層級比較高的時候發生

在層級低的地方,即遠看地球的時候是不用偏移,這裡都沒有作判斷處理

protected void computeTextureTransform(DrawContext dc, SurfaceTile tile, Transform t)
    {
        Sector st1 = tile.getSector();
        Sector st = new Sector(st1.getMinLatitude().addDegrees(0.0029), st1.getMaxLatitude().addDegrees(0.0029), st1.getMinLongitude().addDegrees(-0.0045), st1.getMaxLongitude().addDegrees(-0.0045));

修改getIntersectingTiles函式,這種臨時偏移方案會導致相機對切片錯誤裁剪
 protected Iterable<SurfaceTile> getIntersectingTiles(DrawContext dc, SectorGeometry sg,
        Iterable<? extends SurfaceTile> tiles)
    {
        ArrayList<SurfaceTile> intersectingTiles = null;

        for (SurfaceTile tile : tiles)
        {
            Sector st1 = tile.getSector();
            Sector st = new Sector(st1.getMinLatitude().addDegrees(0.0029), st1.getMaxLatitude().addDegrees(0.0029), st1.getMinLongitude().addDegrees(-0.0045), st1.getMaxLongitude().addDegrees(-0.0045));

新增isTileVisibleEx 代替原來isTileVisible,主要在墨卡託投影圖層呼叫這個即可,其他地方呼叫不用改
private boolean isTileVisibleEx(DrawContext dc, MercatorTextureTile tile)
    {
        //        if (!(tile.getExtent(dc).intersects(dc.getView().getFrustumInModelCoordinates())
        //            && (dc.getVisibleSector() == null || dc.getVisibleSector().intersects(tile.getSector()))))
        //            return false;
        //
        //        Position eyePos = dc.getView().getEyePosition();
        //        LatLon centroid = tile.getSector().getCentroid();
        //        Angle d = LatLon.greatCircleDistance(eyePos.getLatLon(), centroid);
        //        if ((!tile.getLevelName().equals("0")) && d.compareTo(tile.getSector().getDeltaLat().multiply(2.5)) == 1)
        //            return false;
        //
        //        return true;
        //
        Sector st1 = tile.getSector();
        Sector st = new Sector(st1.getMinLatitude().addDegrees(0.0029).getDegrees() > 90.0 ? Angle.fromDegrees(90.0) : st1.getMinLatitude().addDegrees(0.0029),
            st1.getMaxLatitude().addDegrees(0.0029),
            st1.getMinLongitude().addDegrees(-0.0045).getDegrees() < -180.0 ? Angle.fromDegrees(-180.0) : st1.getMinLongitude().addDegrees(-0.0045),
            st1.getMaxLongitude().addDegrees(-0.0045));



        Extent et = Sector.computeBoundingBox(dc.getGlobe(), dc.getVerticalExaggeration(), /*this.getSector()*/st);

        return /*tile.getExtent(dc)*/et.intersects(
            dc.getView().getFrustumInModelCoordinates())
            && (dc.getVisibleSector() == null || dc.getVisibleSector()
            .intersects(/*tile.getSector()*/st));
    }

相關推薦

worldwind學習worldwindjava新增google中國衛星切片糾偏

1.worldwindjava新增谷歌衛星圖層 /* * Copyright (C) 2017 United States Government as represented by the Administrator of the * National Aeronau

深度學習基於im2col的展開Python實現卷積池化

一、回顧 上一篇 我們介紹了,卷積神經網的卷積計算和池化計算,計算過程中視窗一直在移動,那麼我們如何準確的取到視窗內的元素,並進行正確的計算呢? 另外,以上我們只考慮的單個輸入資料,如果是批量資料呢? 首先,我們先來看看批量資料,是如何計算的 二、批處理 在神經網路的

worldwind學習worldwind android版新增天地圖切片

在國內還是天地圖速度快又清晰,google中國版的有偏移,國外版的被封鎖,還是天地圖首選! /* * Copyright (c) 2017 United States Government as represented by the Administrator of t

原始碼學習window 新增 view

此類文章主要是用來記錄學習原始碼的過程,更多的參考別人的分析過程自己去追蹤原始碼,然後做下的記錄。看 Android 原始碼是一個痛苦的過程,之前幾次嘗試都以失敗而告終,這裡把這個過程記錄下來,算是對自己的一種激勵。 下面的所有原始碼都是基於Andro

Python學習python爬蟲Google翻譯的實現

        由於最近的學習,需要把相關的中文語料進行翻譯,自然而然想到爬蟲獲取,主要嘗試了谷歌翻譯和有道翻譯。 一、谷歌翻譯 1.1  所需模組(Python 2.7)          ①re          ②urllib          ③urllib2  

Redis學習Redis筆記(一)——特點、基礎命令資料結構

更新時間:2018-10-13 Redis的特性 速度快 持久化(斷電不丟資料) 多種資料結構 支援多種客戶端語言 功能豐富 操作簡單 主從複製 高可用,分散式 Redis的通用命令 key

機器學習交叉驗證,K折交叉驗證的偏差方差分析

交叉驗證 部分參考:模型選擇中的交叉驗證方法綜述,山西大學,範永東(這是一篇碩士論文,原文內容有點囉嗦,存在一些錯誤。本文對其交叉驗證部分校對整理) 交叉驗證是一種通過估計模型的泛化誤差,從而進行模型選擇的方法。沒有任何假定前提,具有應用的普遍性,操

C++學習vector的使用,輸入一串數字,輸出相鄰---ShinePans

/* *連續使用cin輸入,輸入進vector,輸入一串數字,輸出相鄰和 */ #include <iostream> #include <string> #include <vector> #include <cctype>

深度學習Ubuntu16.04下出現這個錯誤ImportError: No module named google.protobuf.internal

/***************************************************************************************************

react學習關於react框架使用的一些細節要點的思考

through 私有變量 col 層級 -1 turn ech react 子函數 ( _(:3 」∠)_給園友們提個建議,無論是API文檔還是書籍,一定要多看幾遍!特別是隔一段時間後,會有意想不到的收獲的) 這篇文章主要是寫關於學習react中的一些自己的思考: 1.se

機器學習隨機森林 Random Forest 得到模型後,評估參數重要性

img eas 一個 increase 裏的 sum 示例 增加 機器 在得出random forest 模型後,評估參數重要性 importance() 示例如下 特征重要性評價標準 %IncMSE 是 increase in MSE。就是對每一個變量 比如 X1

Hibernate學習 —— 抓取策略(註解方式)

屬性的方法 ould per hql 項目 操作記錄 新建 應用程序 span 當應用程序須要在關聯關系間進行導航的時候。hibernate怎樣獲取關聯對象的策略。 抓取策略的方式: FetchType.LAZY:懶載入。載入一個實體時。定

Python學習Python解決漢諾塔問題

次數 代碼 int 解題思路 move python學習 求解 color 印度 參考文章:http://www.cnblogs.com/dmego/p/5965835.html 一句話:學程序不是目的,理解就好;寫代碼也不是必然,省事最好;拿也好,查也好,解決問題就好

知識學習Sublime Text 快捷鍵精華版

輸入 效果 不同的 文件夾 nbsp enter 尾插 文件瀏覽 相同 1 Sublime Text 3 快捷鍵精華版 2 Ctrl+Shift+P:打開命令面板 3 Ctrl+P:搜索項目中的文件 4 Ctrl+G:跳轉到第幾行 5 Ctrl+W:關

機器學習主成分分析PCA(Principal components analysis)

大小 限制 總結 情況 pca 空間 會有 ges nal 1. 問題 真實的訓練數據總是存在各種各樣的問題:  1、 比如拿到一個汽車的樣本,裏面既有以“千米/每小時”度量的最大速度特征,也有“英裏/小時”的最大速度特征,

機器學習1 監督學習應用與梯度下降

例如 tla ges 機器 fprintf lns 找到 輸入 style 監督學習 簡單來說監督學習模型如圖所示 其中 x是輸入變量 又叫特征向量 y是輸出變量 又叫目標向量 通常的我們用(x,y)表示一個樣本 而第i個樣本 用(x(i),y(i))表示 h是輸出函

機器學習EM的算法

log mea www 優化 問題 get href ive 路線 EM的算法流程: 初始化分布參數θ; 重復以下步驟直到收斂: E步驟:根據參數初始值或上一次叠代的模型參數來計算出隱性變量的後驗概率,其實就是隱性變量的期望。作為隱藏變量的

機器學習DBSCAN Algorithms基於密度的聚類算法

多次 使用 缺點 有效 結束 基於 需要 att 共享 一、算法思想: DBSCAN(Density-Based Spatial Clustering of Applications with Noise)是一個比較有代表性的基於密度的聚

機器學習數據預處理之將類別數據轉換為數值

行數據 pri and slab form ces nbsp 遍歷 encode 在進行python數據分析的時候,首先要進行數據預處理。 有時候不得不處理一些非數值類別的數據,嗯, 今天要說的就是面對這些數據該如何處理。 目前了解到的大概有三種方法: 1,通過LabelE

日常學習搜索/遞歸codevs2802 二的冪次方題解

sni trac mil amp 方法 data font 經典 註意 轉載請註明出處 [ametake版權全部]http://blog.csdn.net/ametake歡迎來看 題目描寫敘述 Description 不論什麽一個正