POST
|
Sebastien, When you publish a Stream Service you can specify an ArcGIS Server service layer that contains related features. The use case that this addresses is where the geographic location of your data does not change, but data attributes change. It sounds like your traffic light data works like this. To publish a Stream Service that references a map/feature service containing location data, you specify the url to the map or feature service layer in the "Related Features" text box of the "Publish Stream Service" dialog. The image below shows using the first layer of a map service named Gages: When the JavaScript API Stream Layer is added to a map, it will first query the "Related Features" url to get the locations of the data. Then when a message is received from the stream service, it finds the feature that has the same Track_ID as the incoming message and updates the attributes of the existing feature with the attributes contained in the new message. To use the related features capability, the Track_ID field of the Geoevent Definition must have the same name as the field in the Map/Feature Service layer. For instance if your traffic light location data has a field named Light_ID, then messages that are coming from your stream service must also contain a field named Light_ID. --James Cardona
... View more
08-31-2015
12:23 PM
|
0
|
0
|
1587
|
POST
|
Sebastien, I agree with RJ that creating a custom application using the JavaScript API is the best way to accomplish all of the requirements. A sample that shows how to create a unique value renderer can be found at Unique value renderer | ArcGIS API for JavaScript. The sample uses a Feature Layer, but applying the renderer to a Stream Layer is the same. The number of graphics displayed per TrackId is controlled by the "maximumTrackPoints" property of the Stream Layer. The default value is 1, meaning that when a new message is received by the Stream Layer, if there is an existing graphic with the same TrackId field value, the existing graphic is removed and a new graphic is added. The Stream Layer uses the "trackIdField" property of a Stream Service to determine which message attribute contains the TrackId value. If your Stream Service does not specify a field to use for the TrackId, then the field name can be specified in the Stream Layer constructor. For example: var layer = new StreamLayer(streamLayerUrl, { trackIdField: "fieldName" }); --James Cardona
... View more
08-14-2015
06:54 AM
|
1
|
0
|
1587
|
POST
|
I use the code at the end of this post to send csv data to a GeoEvent Processor tcp text input. When messages sent to a tcp-text input are not processed, I find a lot of the time that I have set the tcp-text input in GeoEvent Processor to expect a GeoEvent Definition in the incoming messages but the definition name is not the first attribute in each message? import os, sys
import time, argparse
import socket
def sendData(sock, dataPath, interval):
dataFile = None
i = 0
try:
interval = float(interval / 1000.0)
#open simulation data file and send data
dataFile = open(dataPath, "r")
print "Opened data file: %s" % dataPath
for l in dataFile:
sock.send(l)
time.sleep(interval)
dataFile.close()
dataFile = None
return True
except Exception as e:
raise Exception("Error sending data: %s" % e)
finally:
if dataFile:
dataFile.close()
#make argument parser to handle user command line input
parser = argparse.ArgumentParser(description="Start a simulated data feed for a GeoEvent Processor tcp text input")
parser.add_argument("-d", "--data", help="path to file containing csv data. Default is ../data/sources/AsdiUal_sub.csv", default="../data/sources/AsdiUal_sub.csv")
parser.add_argument("-p", "--port", help="tcp socket port. Default is 5565", type=int, default=5565)
parser.add_argument("-n", "--name", help="host name of server to connect to. Default is 'localhost'", default="localhost")
parser.add_argument("-i", "--interval", help="interval in milliseconds between messages. Default is 500. Maximum interval is 5 seconds", type=int, default=500)
if __name__ == "__main__":
args = parser.parse_args()
if args.interval > 5000:
print "Warning: interval cannot be more than 5 seconds. Setting interval to 5 seconds"
args.interval = 5000
if args.interval < 0:
print "Warning: Invalid interval value. Setting interval to default value"
args.interval = 1000
#begin simulation
tcpSocket = None
cont = True
try:
#Check if data file exists
if not os.path.exists(args.data):
raise Exception("Data file not found: %s." % args.data)
#open socket
tcpSocket = socket.create_connection((args.name, args.port))
print "Opened tcp socket on %(name)s:%(port)s" % {"name": args.name, "port": args.port}
while cont:
sendData(tcpSocket, args.data, args.interval)
except Exception as e:
print "Error: %s" % e
finally:
if tcpSocket:
tcpSocket.close()
... View more
05-01-2014
10:13 AM
|
0
|
0
|
865
|
POST
|
Thomas, At version 3.7 of the javascript api, the message event changed. The event now receives an array of raw features instead of a Graphic. This was done to allow a developer to intercept a message from the websocket connection before the message got converted to a graphic and added to the map. To get the Graphic that was added to the map, a developer should handle the graphic-add event on the layer. I've attached the updated sample; the change is on line 164. The updated sample will be included with the next documentation updates. --James Cardona
... View more
12-10-2013
06:10 AM
|
0
|
0
|
429
|
Title | Kudos | Posted |
---|---|---|
1 | 08-14-2015 06:54 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|