Worldwind - 形状总是显示在图像之上?

2024-04-21

我在 WorldWindowGLJPanel 的图层列表中添加了两个图层。其中之一是包含形状的 RenderableLayer,另一个是包含光栅图像的 BasicTiledImageLayer。 (一层包含一个对象)。问题是,当我使用图层管理器​​面板更改图层顺序时,只有具有相同类型图层更改和形状的对象的顺序始终显示在图像顶部,无论它们的顺序如何。有办法纠正这个问题吗?

截图:

我的代码如下:

    /*
 * Copyright (C) 2012 United States Government as represented by the Administrator of the
 * National Aeronautics and Space Administration.
 * All Rights Reserved.
 */
package gov.nasa.worldwindx.examples;

import java.awt.Cursor;
import java.io.File;

import javax.swing.SwingUtilities;

import org.w3c.dom.Document;

import gov.nasa.worldwind.BasicFactory;
import gov.nasa.worldwind.WorldWind;
import gov.nasa.worldwind.avlist.AVKey;
import gov.nasa.worldwind.avlist.AVList;
import gov.nasa.worldwind.avlist.AVListImpl;
import gov.nasa.worldwind.cache.FileStore;
import gov.nasa.worldwind.data.TiledImageProducer;
import gov.nasa.worldwind.formats.shapefile.ShapefileLayerFactory;
import gov.nasa.worldwind.formats.shapefile.ShapefileRecord;
import gov.nasa.worldwind.formats.shapefile.ShapefileRenderable;
import gov.nasa.worldwind.geom.Sector;
import gov.nasa.worldwind.layers.Layer;
import gov.nasa.worldwind.util.Logging;
import gov.nasa.worldwind.util.WWIO;
import gov.nasa.worldwindx.examples.dataimport.DataInstallUtil;
import gov.nasa.worldwindx.examples.util.ExampleUtil;
import gov.nasa.worldwindx.examples.util.RandomShapeAttributes;

/**
 * Illustrates how to import ESRI Shapefiles into World Wind. This uses a <code>{@link ShapefileLayerFactory}</code> to
 * parse a Shapefile's contents and convert the shapefile into an equivalent World Wind shape.
 *
 * @version $Id: Shapefiles.java 3212 2015-06-18 02:45:56Z tgaskins $
 */
public class ShapeRaster extends ApplicationTemplate
{
    protected static final String BASE_CACHE_PATH = "Examples/"; // Define a subdirectory in the installed-data area

    // This example's imagery is loaded from the following class-path resource.
    protected static final String IMAGE_PATH = "gov/nasa/worldwindx/examples/data/craterlake-imagery-30m.tif";

    public static class AppFrame extends ApplicationTemplate.AppFrame
    {
        private static final long serialVersionUID = -7733929990972508866L;

        public AppFrame()
        {
            ShapefileLayerFactory factory = new ShapefileLayerFactory();

            // Specify an attribute delegate to assign random attributes to each shape file record.
            final RandomShapeAttributes randomAttrs = new RandomShapeAttributes();
            factory.setAttributeDelegate(new ShapefileRenderable.AttributeDelegate()
            {
                @Override
                public void assignAttributes(ShapefileRecord shapefileRecord,
                    ShapefileRenderable.Record renderableRecord)
                {
                    renderableRecord.setAttributes(randomAttrs.nextAttributes().asShapeAttributes());
                }
            });

            // Load the shape file. Define the completion callback.
            factory.createFromShapefileSource("testData/shapefiles/TM_WORLD_BORDERS-0.3.shp",
                new ShapefileLayerFactory.CompletionCallback()
                {
                    @Override
                    public void completion(Object result)
                    {
                        final Layer layer = (Layer) result; // the result is the layer the factory created
                        layer.setName(WWIO.getFilename(layer.getName()));
                        layer.clearList();

                        // Add the layer to the World Window's layer list on the Event Dispatch Thread.
                        SwingUtilities.invokeLater(new Runnable()
                        {
                            @Override
                            public void run()
                            {
                                AppFrame.this.getWwd().getModel().getLayers().add(layer);
                            }
                        });
                    }

                    @Override
                    public void exception(Exception e)
                    {
                        Logging.logger().log(java.util.logging.Level.SEVERE, e.getMessage(), e);
                    }
                });

            // Show the WAIT cursor because the installation may take a while.
            this.setCursor(new Cursor(Cursor.WAIT_CURSOR));

            // Install the imagery on a thread other than the event-dispatch thread to avoid freezing the UI.
            Thread t = new Thread(new Runnable()
            {
                public void run()
                {
                    installImagery();

                    // Restore the cursor.
                    setCursor(Cursor.getDefaultCursor());
                }
            });

            t.start();
        }

        protected void installImagery()
        {
            // Download the source file.
            File sourceFile = ExampleUtil.saveResourceToTempFile(IMAGE_PATH, ".tif");

            // Get a reference to the FileStore into which we'll install the imagery.
            FileStore fileStore = WorldWind.getDataFileStore();

            // Install the imagery into the FileStore.
            final Layer layer = installSurfaceImage("Crater Lake Imagery 30m", sourceFile, fileStore);
            if (layer == null)
                return;

            // Display a layer with the new imagery. Must do it on the event dispatch thread.
            SwingUtilities.invokeLater(new Runnable()
            {
                public void run()
                {
                    // Add the layer created by the install method to the layer list.
                    insertBeforePlacenames(AppFrame.this.getWwd(), layer);

                    // Set the view to look at the installed image. Get the location from the layer's construction
                    // parameters.
                    AVList params = (AVList) layer.getValue(AVKey.CONSTRUCTION_PARAMETERS);
                    Sector sector = (Sector) params.getValue(AVKey.SECTOR);
                    ExampleUtil.goTo(getWwd(), sector);
                }
            });
        }

        protected Layer installSurfaceImage(String displayName, Object imageSource, FileStore fileStore)
        {
            // Use the FileStore's install location as the destination for the installed imagery. The default install
            // location is the FileStore's area for permanent storage.
            File fileStoreLocation = DataInstallUtil.getDefaultInstallLocation(fileStore);

            // Create a unique cache name that specifies the installed data's location within the FileStore.
            String cacheName = BASE_CACHE_PATH + WWIO.replaceIllegalFileNameCharacters(displayName);

            // Create a parameter list specifying the install location information.
            AVList params = new AVListImpl();
            params.setValue(AVKey.FILE_STORE_LOCATION, fileStoreLocation.getAbsolutePath());
            params.setValue(AVKey.DATA_CACHE_NAME, cacheName);
            params.setValue(AVKey.DATASET_NAME, displayName);

            // Create a TiledImageProducer to install the imagery.
            TiledImageProducer producer = new TiledImageProducer();
            try
            {
                // Configure the TiledImageProducer with the parameter list and the image source.
                producer.setStoreParameters(params);
                producer.offerDataSource(imageSource, null);

                // Install the imagery.
                producer.startProduction();
            }
            catch (Exception e)
            {
                producer.removeProductionState(); // Clean up on failure.
                e.printStackTrace();
                return null;
            }

            // Extract the data configuration document from the installed results. If the installation successfully
            // completed, the TiledImageProducer should always contain a document in the production results, but test
            // the results anyway.
            Iterable<?> results = producer.getProductionResults();
            if (results == null || results.iterator() == null || !results.iterator().hasNext())
                return null;

            Object o = results.iterator().next();
            if (o == null || !(o instanceof Document))
                return null;

            // Construct a Layer by passing the data configuration document to a LayerFactory.
            Layer layer = (Layer) BasicFactory.create(AVKey.LAYER_FACTORY, ((Document) o).getDocumentElement());

            // The layer factory creates layers that are initially disabled, so enable the layer.
            layer.setEnabled(true);

            return layer;
        }
    }

    public static void main(String[] args)
    {
        start("World Wind Shapefiles", AppFrame.class);
    }
}

它取决于为 shapefile 中的数据创建的形状。由 ShapefileLayerFactory 创建的形状可以是表面形状类型,例如 SurfacePlygon 或 SurfaceCircle。这些形状始终位于图像之上。其他形状(例如 ExtrudedPolygon)可能有高度。对于这种类型的形状,如果高度大于 0,无论如何它都会位于图像上方。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Worldwind - 形状总是显示在图像之上? 的相关文章

  • 如何使用 Openlayers 文本图层编辑弹出窗口

    我正在使用 Openlayers 创建一个包含大约 1000 多个点的地图 目前 当我单击一个点的图标时 该点的描述会显示在弹出窗口中 要退出弹出窗口 我需要再次单击同一点的图标 有没有办法修改此代码 以便我可以按关闭按钮或单击地图上的任意
  • sf 对象的大小图例不会显示正确的符号

    有谁知道为什么传说size审美的BIR74不会显示点大小而是矩形 如果答案是肯定的 我该如何解决这个问题 可重现的例子 library sf devtools install github tidyverse ggplot2 library
  • JavaFX 缩放形状而不移动原点

    我的形状的缩放能力有问题 我想使用我自己绘制的坐标系 其中包含一些形状 这些形状需要缩放函数 缩放形状后 它们会移动 因为缩放发生在每个形状的中心 为了对这个运动做出反应 我重新计算原点 但如果我缩放多次 形状仍然会偏离原点 我不知道为什么
  • 创建等腰梯形形状

    我想知道是否可以用 CSS 生成类似的东西 我也想知道 这是提出这样问题的合适地方吗 我没有尝试过任何代码 我已经用 Photoshop 完成了棕色图像 谢谢你的帮助 这个形状 一个等腰梯形 http en wikipedia org wi
  • 如何使用 GDAL 从 tiff 和 4 个角纬度和经度创建 geotiff [关闭]

    Closed 这个问题正在寻求书籍 工具 软件库等的推荐 不满足堆栈溢出指南 help closed questions 目前不接受答案 我有一张没有 TIFF 格式地理数据的图像 地图 我需要从我的图像中获取 GeoTIFF 文件 我的地
  • 使用 GeoPandas 计算其他多边形内的多边形面积

    我有两个GeoSeries df1 gpd GeoSeries Polygon 0 0 2 0 2 2 0 2 Polygon 1 5 1 5 4 2 4 4 2 4 Polygon 1 3 5 3 3 5 1 2 5 Polygon 1
  • 如何获得概率层的形状?

    我正在使用 TensorFlow 概率层构建模型 当我做 model output shape 我收到错误 AttributeError UserRegisteredSpec object has no attribute shape 如果
  • 如何使用 Python OpenCV 优化圆检测?

    我看过几页关于在 python 中使用 opencv 优化圆检测的页面 所有这些似乎都针对特定图片的具体情况 cv2 HoughCircles 的每个参数的起点是什么 由于我不确定推荐值是什么 因此我尝试循环范围 但这并没有产生任何有希望的
  • Delphi7,按向上键时进行形状​​跳跃

    我想在玩家按下UP键时进行形状 跳跃 所以我能想到的最好的就是这个 但我使用的方法很糟糕并且有问题 形状坐标 shape1 top 432 procedure TForm1 FormKeyDown Sender TObject var Ke
  • 地理数据网络服务

    我正在考虑编写一个程序来检查英国议会议员最近提出的一些里程声明 实际上大约有 45 000 个里程 我所掌握的数据相当准确 旅行的出发地和目的地通常仅 在城镇级别提供 我想做的基本上是查看他们提交的里程数据 查看从网络服务获得的 计算 里程
  • 如何从 NoSQL DBMS(如 DynamoDB)存储 GPS 坐标并搜索半径范围内的地点

    我的团队需要像 DynamoDB 这样的 DBMS 来存储大量数据 主要是位置和坐标 我考虑过使用一些基于 GIS 的 DBMS 例如 PostGIS 并在 POINT 上建立索引 但 DynamoDB 似乎非常适合我们的使用 存储坐标并快
  • GeoAlchemy2:获取某个点的经纬度

    考虑以下SQLAalchemy http www sqlalchemy org GeoAlchemy2 http geoalchemy 2 readthedocs org en 0 2 6 index html具有几何字段的 ORM fro
  • 查找信标的两个地理位置之间的点

    假设我们有两个beacons放置在道路两侧 我们知道他们的latitude and longitude它们所在的位置 我们将它们视为一个位置 我们还知道distance两者之间以米为单位beacons 使用半正矢公式测量 我们的设备正在这两
  • 如何使用 Java2D 图形正确绘制点间距很近的粗线?

    我正在尝试使用 Java2D 绘制地图 当我的地图缩小时 我的道路上充满了绘画制品 这是绘制完整的美国州时屏幕的一小部分 放大后 这是一段相似的路段 使用的线条样式是一条蓝色实线 其宽度缩放为相当于 2 个像素 我尝试了各种渲染提示和行连接
  • 可绘制资源中带有形状的文本

    我可以在可绘制资源中创建文本形状吗 我在谷歌上搜索了很多 但什么也没找到 这是我的绘图文件
  • 将开放曲线转换为有序像素列表:使用 numpy 的 Python 测试代码

    我有一个 numpy 数组中的开放曲线的图像 我需要构建一个根据曲线上的位置排序的点坐标列表 我写了一个剧本草稿 http dip4fish blogspot com 2011 06 converting open curve to lis
  • 将 R data.frame 转换为 Javascript 数组

    我想将数据框的某些列保存为特定格式 JavaScript 格式 我尝试过使用toJSON from rjson包但这不起作用 我的结果应该是这样的 http leaflet github io Leaflet markercluster e
  • 如何在 android 中使用 XML 形状创建向右箭头(V 形)? [关闭]

    Closed 这个问题需要多问focused help closed questions 目前不接受答案 How to create a right facing arrow using xml shapes in android like
  • SVG中的地理识别位置(GeoLocation/GeoTag)

    我想知道如何对 SVG 地图进行地理标记 我的搜索结果 地理标签以元数据格式提供 例如Exif http www awaresystems be imaging tiff tifftags privateifd gps html XMP h
  • 如何将美国人口普查局的州级形状文件合并为全国性形状

    人口普查局不提供全国范围内公共使用微数据区域的形状文件 美国社区调查中可用的最小地理区域 我尝试用几种不同的方法将它们结合起来 但即使是消除重复标识符的方法一旦到达加利福尼亚州也会崩溃 我是在做一些愚蠢的事情还是需要一个困难的解决方法 下面

随机推荐

  • 如何在Python 3.6中安装pymssql模块?

    我已经阅读了一些涉及 FreeTDS Wheel git 和 github 的文档 但在我的带有 Python 3 6 的 Windows 10 PC 上没有任何功能 但我需要安装它 我正在开发一个项目 我对已经安装在我的电脑中的 mssq
  • c# LOESS/LOWESS 回归 [关闭]

    Closed 这个问题正在寻求书籍 工具 软件库等的推荐 不满足堆栈溢出指南 help closed questions 目前不接受答案 您知道执行 LOESS LOWESS 回归的 net 库吗 最好是免费 开源 端口来自java htt
  • 从 Symfony2 中的实体和存储库登录的正确方法

    在 symfony2 架构中记录来自实体或存储库类的消息或错误的方法是什么 在 symfony1 中 您可以使用单例来杀死小狗 方法是执行以下操作以从任何地方获取记录器 sfContext getInstance gt getLogger
  • 如何在 Vapor 3/Fluent 中记录 SQL 语句?

    看起来在 Vapor 2 中你可以这样做 let query
  • 更改组织模式新一天开始的时间

    我使用组织模式来计时我的工作 有时我会工作几个小时到午夜 例如 我记录的时间从 2013 年 6 月 3 日晚上 10 点开始 到 2013 年 6 月 4 日凌晨 2 点结束 组织模式在凌晨 0 点进行划分 开始新的一天 但如果将 0am
  • Excel创建乘法条件排名

    我试图在此图表中进行有条件排名 On the right you can see the total score and ranking from the Match 1 2 3 sum on line A and C I have a t
  • 使用 Twitter Bootstrap 的水平形式内的普通(垂直)形式

    我想要一个在第一层具有水平布局的表单 但是在一行内可以有一个 内联 表单 我想要一个垂直 默认 布局 有没有一种简单的方法可以实现这一目标 Note form inline没有做我正在寻找的事情 因为它没有将内部标签放在输入的顶部 到目前为
  • Java 中是否有与 StringWriter 等效但内部带有 StringBuilder 的东西?

    我注意到 StringWriter 在内部使用 StringBuffer 但是 如果您不需要同步开销 是否有与 StringWriter 等效的内部使用 StringBuilder 的方法 如果你恰好使用 Apache Commons IO
  • 允许 Rust 格式中未使用的命名参数!() 系列

    Given format red reset text red RED blue BLUE reset RESET 编译器退出并出现错误 error named argument never used gt example rs 1 47
  • 提取后视频帧是颠倒的

    我的问题是 当我使用 opencv 将视频提取到帧中时 有时我得到的帧会翻转 这在我的机器 窗口 和 VM ubuntu 上都发生过 但是我测试的一些视频 帧不翻转 所以 我想知道应该在我的代码中更改 添加哪些因素或哪些内容 以使提取内容无
  • WebSocket 握手:意外响应代码:404

    正在编写我的第一个 websocket 程序并且正在得到 WebSocket 握手 意外响应代码 404 加载网页时出错 我使用的是 JDK 1 7 和 jboss 8 wildfly8 0 有人可以帮忙吗 window onload in
  • 通过代码更改 Vaadin 7 中的主题

    我正在 Vaadin 7 中做一个项目 我需要更改页面的主题 在 Vaadin 6 中 有一个名为 setTheme 的函数 这样我就可以在代码中的任何位置使用该函数更改主题 但是 在 Vaadin 7 中 我找不到类似的东西 我知道会有办
  • SLES Apache Solr start.jar,无法访问 jarfile

    我在启动 Apache Solr 搜索时遇到一些问题 在我的 SLES 11 64 位服务器上安装 java 7 后 我将 solr 3 6 1 解压到 srv apache solr 3 6 0 之后我想启动该软件 但是当我尝试时 jav
  • 如何解决此错误消息:错误:virtualenvwrapper 无法在路径中找到 virtualenv?

    我正在尝试在 Mac 上安装 Python Goose 我运行的是 OSX 10 9 3 安装 Goose 的第一步是 mkvirtualenv no site packages goose 但是 当我运行此命令时 我收到以下错误消息 错误
  • Xcode在哪里打开快速搜索?

    我不知道如何让它索引我的项目文件 快速打开应该搜索任何open项目 曾经有一个路径首选项 但我相信它在 3 1 中被删除了
  • 交换数组中的奇数和偶数

    我在这个网站上看到了这段代码 它使用一种方法对数组进行排序 偶数在前面 奇数在数组后面 我想知道你是否可以做同样的事情 除了先出现奇数 然后出现偶数 我尝试过但没有成功 我是java编码新手 我想测试递归 public class Recu
  • 导致 ValueError: 'b' in __slots__ 与类变量冲突的数据类和槽

    我不明白错误消息 也找不到其他问题和答案来帮助我理解这一点 MWE 使用 Python 3 9 2 进行测试 我知道有一个slots TruePython 3 10 数据类中的参数 但这不是这里的选择 错误输出 Traceback most
  • 如何查看Vite项目中的公共目录进行热加载?

    我有一个使用 Vite 配置的 React 项目 热重载效果很好 但我使用react i18next对于多语言支持 这是我的结构 public gt en gt translation json gt ru gt translation j
  • 如何确定一系列循环数据中的高值和低值?

    我有一些代表周期性运动的数据 所以 它从高点到低点 然后又回来 如果你要绘制它 它就像一个正弦波 然而 每个周期的幅度略有不同 我想列出整个序列中的每个最大值和最小值 如果有 10 个完整的周期 我最终会得到 20 个数字 其中 10 个为
  • Worldwind - 形状总是显示在图像之上?

    我在 WorldWindowGLJPanel 的图层列表中添加了两个图层 其中之一是包含形状的 RenderableLayer 另一个是包含光栅图像的 BasicTiledImageLayer 一层包含一个对象 问题是 当我使用图层管理器