Calculate Geometry with GeoEvent

3491
0
09-18-2017 01:14 PM

Calculate Geometry with GeoEvent

I've worked with customers where there has been a need to calculate geometry from two fields.  While many inputs provide the option to do this for you, in some cases you will need to use the Field Calculator to do this.  For example, a customer has Calls For Service (CFS) being added to a database table.  The latitude and longitude values are stored in a text field where there is no formatting such as a negative for the longitude, and a period for the decimal degrees.  Ex:

LongitudeLatitude
9322418544898853
9327537144946643
9322149444917689

The customer's end goal is to update an enterprise geodatabase feature class with all attributes, including the geometry.  The issue was how to calculate the geometry for the feature service.  Here are the steps:

1.  First, we published the table as a map service.

Note:  To publish data that is being referenced at least one feature class must exist within the map.  We added an empty feature class to the map so that publishing is possible.

2.  Next, we setup an input in GeoEvent to Poll an ArcGIS Server for Features referencing this table. 

3.  Three additional fields were added to the GeoEvent Definition to accommodate the latitude/longitude values as field type Double, and the geometry. 

4.  In the GeoEvent Service the Long_Double and Lat_Double fields were CAST values from the original Longitude/Latitude fields using the Field Calculator:

5.  The Field Calculator was used again to add the negative to the Long_Double field and to add a decimal by dividing both Long_Double and Lat_Double by 1,000,000:

6.  Now that there are fields of type Double that are formatted correctly, the Geometry field can be calculated.  This expression was a little more complex:

'{' + ' "x":' + Long_Double + ',' + ' "y":' + Lat_Double + ',' + ' "spatialReference":{"wkid":4326} }'

The spatial reference (4326) is for WGS_84 in this example. 

Hint:  An easy way to find the WKID is to search for the coordinate system using ArcMap's Data Frame Properties:

7.  The Field Mapper processor was added to ensure the fields are mapped correctly to the feature service.  Below is a look at the GeoEvent Service:

As the database table was updated GeoEvent successfully converted the Longitude/Latitude values to Doubles, created geometry from these values, and updated the feature service.

Version history
Last update:
‎09-18-2017 01:14 PM
Updated by:
Contributors