Skip to content

Commit ebb4a0a

Browse files
authored
Display wfs layer (#334)
* update api version * change api version to 100.5.0 * change version to 100.5.0 * start updates for java 11 * update java 11 parts * add dependencies for all platforms * Delete module-info.java * Update README Update README to alert Java 11 users to potential exceptions which may occur when running the project. Providing a suggested workaround from the OpenJavaFX docs. * Update README.md * add an integrated mesh layer sample * update arcgis version * use javafx plugin * remove jar task config * update arcgis version * move stage show * add point cloud data to sample data downloads * view point cloud data offline sample * Update build.gradle * change camera viewpoint * remove unused imports * update image * update api version * edit about the data and additional info sections * fix comment * Removed errant full stop * Open Mobile Scene Package (#318) * Gradle script includes path to download mspk file (further work required here) and implementation of sample in Java * Create README.md * Create OpenMobileScenePackage.png * Update typo in README * Updated gradle to point to correct data on AGOL * Update to sample code following review * Updates to ReadMe following review * Additional update to read me to include isDirectReadSupported.get * Updated from markdown to HTML * Remove id tags from HTML * Map reference scale (#319) * Create MapReferenceScaleSample.java * Set up MVC structure for sample * Set up basic map with MVC structure * Added label which updates scale of map as it changes * Set up means to change the map view to the selected reference scale * Set up check boxes for map layers * Update MapReferenceScaleController.java * Update MapReferenceScaleController.java * Allow string in combobox, split to return double to feed into map reference scale * Link checkbox with map layer to set reference scale * Method descriptions and remove unused imports * Fix indents * Create MapReferenceScale.png * Create README.md * Convert markdown to HTML * Addressed comments from review. ComboBox now double, vBoxes will load after map has loaded * Add a method to handle setting the reference scale when interacting with the combobox and the scale sync button. * Code updates following review removed unneeded label, added if loaded statement, and refactored map reference scale. Also updated Readme to account for behavior change. * move checkbox logic in with instanceof check * Update MapReferenceScaleController.java * Corrected title for sample * Merge master into dev (#322) * Camera controller US english update (#320) * Replace "aeroplane" with "plane" in README and code * Update image to show corrected spelling * Fix grammar * Updates to Tiled Layer to show support for .tkpx files (#321) * Updates to tiled layer, including .tpkx support * Update tile cache readme to include support .tpkx * Allow downloading of non zip sample data (#324) * Allow downloading of non zip sample data * point scene layer sample (#323) * point scene layer sample * Merge master into Dev (#329) * Camera controller US english update (#320) * Replace "aeroplane" with "plane" in README and code * Update image to show corrected spelling * Fix grammar * Updates to Tiled Layer to show support for .tkpx files (#321) * Updates to tiled layer, including .tpkx support * Update tile cache readme to include support .tpkx * Update slider to show values from 1-5 rather than 0-5 (#328) * remove online elevation data source (#327) * remove online elevation data source * remove unneeded ArcGISScene object * View content beneath terrain surface (#325) * Initiating sample with Scene URL * add done loading listener for changes * portal item entry for data * Add readme and image * Update ViewContentBeneathTerrainSurfaceSample.java * update build and refactor float code * Update ViewContentBeneathTerrainSurfaceSample.java * Add layer view state changed listener * Update ViewContentBeneathTerrainSurface.png * Address comments following review * update comment for add done loading listener on to scene * Update README.md * remove unused imports * initialize sample * remove unneeded loadAsync call * Update DisplayWFSLayerSample.java * add readme and image * remove unused imports and use web mercator points * Convert markdown to HTML * Add copyright statement, remove redundant code commenting * Add NavigationChangedEvent as relevant API * remove methods from Relevant API section * Refactor method name
1 parent ab2bf1f commit ebb4a0a

File tree

3 files changed

+187
-0
lines changed

3 files changed

+187
-0
lines changed
508 KB
Loading
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
/*
2+
* Copyright 2019 Esri.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
17+
package com.esri.samples.ogc.display_wfs_layer;
18+
19+
import com.esri.arcgisruntime.data.QueryParameters;
20+
import com.esri.arcgisruntime.data.ServiceFeatureTable;
21+
import com.esri.arcgisruntime.geometry.Envelope;
22+
import com.esri.arcgisruntime.geometry.Point;
23+
import com.esri.arcgisruntime.layers.FeatureLayer;
24+
import com.esri.arcgisruntime.mapping.ArcGISMap;
25+
import com.esri.arcgisruntime.mapping.Basemap;
26+
import com.esri.arcgisruntime.mapping.Viewpoint;
27+
import com.esri.arcgisruntime.mapping.view.MapView;
28+
import com.esri.arcgisruntime.ogc.wfs.WfsFeatureTable;
29+
import com.esri.arcgisruntime.symbology.SimpleLineSymbol;
30+
import com.esri.arcgisruntime.symbology.SimpleRenderer;
31+
import javafx.application.Application;
32+
import javafx.scene.Scene;
33+
import javafx.scene.layout.StackPane;
34+
import javafx.stage.Stage;
35+
36+
public class DisplayWFSLayerSample extends Application {
37+
38+
private MapView mapView;
39+
40+
@Override
41+
public void start(Stage stage) {
42+
43+
// create stack pane and JavaFX app scene
44+
StackPane stackPane = new StackPane();
45+
Scene scene = new Scene(stackPane);
46+
47+
// set title, size, and add JavaFX scene to stage
48+
stage.setTitle("Display a WFS Layer");
49+
stage.setWidth(800);
50+
stage.setHeight(700);
51+
stage.setScene(scene);
52+
stage.show();
53+
54+
// create an ArcGISMap with topographic basemap and set it to the map view
55+
ArcGISMap map = new ArcGISMap(Basemap.createTopographic());
56+
mapView = new MapView();
57+
mapView.setMap(map);
58+
59+
// create an initial extent to load
60+
Point topLeft = new Point(-13619002.499764, 6043406.351867);
61+
Point bottomRight = new Point(-13618454.919189, 6042836.793464);
62+
Envelope initialExtent = new Envelope(topLeft, bottomRight);
63+
mapView.setViewpoint(new Viewpoint(initialExtent));
64+
65+
String serviceUrl = "https://dservices2.arcgis.com/ZQgQTuoyBrtmoGdP/arcgis/services/Seattle_Downtown_Features/WFSServer?service=wfs&request=getcapabilities";
66+
String LayerName = "Seattle_Downtown_Features:Buildings";
67+
68+
// create a FeatureTable from the WFS service URL and name of the layer
69+
WfsFeatureTable wfsFeatureTable = new WfsFeatureTable(serviceUrl, LayerName);
70+
71+
// set the feature request mode to manual. The table must be manually populated as panning and zooming won't request features automatically.
72+
wfsFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.MANUAL_CACHE);
73+
74+
// create a feature layer to visualize the WFS features
75+
FeatureLayer wfsFeatureLayer = new FeatureLayer(wfsFeatureTable);
76+
77+
// apply a renderer to the feature layer
78+
SimpleRenderer renderer = new SimpleRenderer(new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, 0xFFFF0000, 3));
79+
wfsFeatureLayer.setRenderer(renderer);
80+
81+
// add the layer to the map's operational layers
82+
map.getOperationalLayers().add(wfsFeatureLayer);
83+
84+
// make an initial call to load the initial extent's data from the WFS, using the WFS spatial reference
85+
populateFeaturesFromServer(wfsFeatureTable, initialExtent);
86+
87+
// use the navigation completed event to populate the table with the features needed for the current extent
88+
mapView.addNavigationChangedListener(navigationChangedEvent -> {
89+
// once the map view has stopped navigating
90+
if (!navigationChangedEvent.isNavigating()) {
91+
populateFeaturesFromServer(wfsFeatureTable, mapView.getVisibleArea().getExtent());
92+
}
93+
});
94+
95+
// add the mapview to the stackpane
96+
stackPane.getChildren().add(mapView);
97+
}
98+
99+
/**
100+
* Create query parameters using the given extent to populate the WFS table from the service
101+
* @param wfsTable the WFS feature table to populate
102+
* @param extent the extent used to define the QueryParameters' geometry
103+
*/
104+
private void populateFeaturesFromServer(WfsFeatureTable wfsTable, Envelope extent){
105+
106+
// create a query based on the current visible extent
107+
QueryParameters visibleExtentQuery = new QueryParameters();
108+
visibleExtentQuery.setGeometry(extent);
109+
visibleExtentQuery.setSpatialRelationship(QueryParameters.SpatialRelationship.INTERSECTS);
110+
// populate the WFS feature table based on the current extent
111+
wfsTable.populateFromServiceAsync(visibleExtentQuery, false, null);
112+
}
113+
114+
/**
115+
* Stops and releases all resources used in application.
116+
*/
117+
@Override
118+
public void stop() {
119+
if (mapView != null) {
120+
mapView.dispose();
121+
}
122+
}
123+
124+
/**
125+
* Opens and runs application.
126+
*
127+
* @param args arguments passed to this application
128+
*/
129+
public static void main(String[] args) {
130+
131+
Application.launch(args);
132+
}
133+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<h1>Display WFS layer</h1>
2+
3+
<p>Display a layer from a WFS service, requesting only features for the current extent.</p>
4+
5+
<p><img src="DisplayWFSLayer.png"/></p>
6+
7+
<h2>Use case</h2>
8+
9+
<p>WFS is an open standard with functionality similar to ArcGIS feature
10+
services. Runtime support for WFS allows you to interoperate with open
11+
systems, which are often used in inter-agency efforts, like those for
12+
disaster relief.</p>
13+
14+
<h2>How to use the sample</h2>
15+
16+
<p>Pan and zoom to see features within the current map extent.</p>
17+
18+
<h2>How it works</h2>
19+
20+
<ol>
21+
<li>Create a <code>WfsFeatureTable</code> with a URL. </li>
22+
23+
<li>Create a <code>FeatureLayer</code> from the feature table and add it to the map.</li>
24+
25+
<li>Add a <code>NavigationChangedListener</code> to the map view and listen for a
26+
<code>NavigationChangedEvent</code>. Check if it <code>!isNavigating()</code> to detect
27+
when the user has stopped navigating the map.</li>
28+
29+
<li>When the user is finished navigating, use
30+
<code>populateFromServiceAsync(...)</code> to load the table with data for the
31+
current visible extent.</li>
32+
</ol>
33+
34+
<h2>Relevant API</h2>
35+
36+
<ul>
37+
<li>FeatureLayer</li>
38+
39+
<li>NavigationChangedEvent</li>
40+
41+
<li>QueryParameters</li>
42+
43+
<li>WfsFeatureTable</li>
44+
</ul>
45+
46+
<h2>About the data</h2>
47+
48+
<p>This service shows building footprints for downtown Seattle. For
49+
additional information, see the underlying service on
50+
<a href="https://arcgisruntime.maps.arcgis.com/home/item.html?id=1b81d35c5b0942678140efc29bc25391">ArcGIS Online</a>.</p>
51+
52+
<h2>Tags</h2>
53+
54+
<p>OGC, WFS, layers, feature, web, service, browse, catalog, interaction cache</p>

0 commit comments

Comments
 (0)