span8
span4
span8
span4
The GeoJSON format provides a way to communicate location data as part of the open JSON (JavaScript Object Notation)specification.The Data Streaming Service in FME Server allows users to easily incorporate this data into a web service.
The example below demonstrates how we can use FME Workbench to produce a string of geoJSON,which once published to FME Server can be used to generate a Direct URL to link the data to an external web service.The second part of the tutorial shows the reverse - how to look ‘behind the scenes' of the web service to find the basic syntax used in this data request.
Open FME Workbench and and select Generate Workspace.Read in the data that you wish to serve and set the writer dataset to GeoJSON format.If you do not have your own data you can use the example provided in this article - this workspace uses an SDF data source detailing bus routes and bus stops in Austin,Texas.
Generate workspace with SDF reader and GeoJSON writer
Note: Be aware you may need to re-project the data depending on the client application.In our example the data has been reprojected to EPSG:4326 for use in OpenLayers.
If the dataset is formed of multiple layers (Feature Types) you can set up a published parameter where the user can request to stream one or many layers.For testing purposes you can select a single layer to read by going into the Reader parameters in the Navigator window and setting theFeature Types to Read.
Location of the Reader Feature Types to Read parameter in FME Workbench
Go to File and select Publish to FME Server.In the Publish Workspace window create a new Repository to save the workspace in and also ensure the Upload Data Files box is checked.
Register the workspace with the Data Streaming Service,select the edit button here to explore the different options and make sure the GeoJSON file has been selected as the writer to stream.
Edit the Data Streaming Properties
Go to the FME Server Web Interface,and on the homepage find and select the newly published workspace underLast Published Workspaces.Run the workspace and the GeoJSON will be returned directly to your browser.
FME Server will return the GeoJSON MIME type in the response header as well the Content-Type;in this case application/json.
Return to the Run Workspace page and expose the Advanced section.This section includes a Direct URL example which can be used directly within a web service to request the GeoJSON.If you change the value of the Feature Types to Read parameter and refresh the Advanced panel you will see a change in the syntax defining this parameter in the request.
Set Feature Types to Read parameter and then get Direct URL from Advanced section of Run Workspace window
The Direct URL obtained above (step 4) can be provided to any client application that consumes GeoJSON.FME Server will dynamically return the data in GeoJSON when the URL is invoked.An example of this has been created using the OpenLayers web page which can be foundhere.The underlying source for this web page is written in JavaScript.To see the syntax for the data request using the FME Server Direct URL right click in the browser and selectView Page Source.
View the FME Server Direct URL used to stream data to an OpenLayers web service
If you are considering creating a data streaming service with FME Server you may also be interested in:Streaming XML with FME Server.
Data used in this article originates from open data made available by the theCity of Austin,Texas.It contains data licensed under the Public Domain Dedication License - City of Austin.
EasyGeocoder - Data Driven Self-Serve Data Transformation
Streaming GeoJSON with FME Server (2015)
Demo Showing Realtime Data Display in Google Earth (KML Network Link Control)
Fun With Flags - Streaming JSON
Creating REST Web Services: 4.First an RPC Web Service (2015)
403 Forbidden Error When Making FME Server Request
Creating REST Web Services: 6.Supporting HTTP POST (2015)
© 2019 亚搏在线Safe Software Inc |Legal