Select to view content in your preferred language

Temporal Renderer w TimeClassBreaksAger in Real-Time

3432
5
Jump to solution
07-16-2015 10:43 AM
CarisaSmith
Deactivated User

I'm struggling to get the Temporal Renderer to work with real-time data.  The renderer seems to work w my UniqueValueRenderer as the ObservationRenderer of the Temporal Renderer, but the Ager doesn't seem to work.  I have been able to get the Temporal Renderer w the Ager working with historic data and a time slider, but w the real-time data it is not working.  I must have some setting incorrect or something somewhere.  I've tried to look on-line but haven't found much and a lot of the ESRI examples for real-time data are not working or there are no hurricanes or earthquakes occurring at this time.  I'm using a Feature Collection Object to create my Feature Layer and I'm NOT using a TimeSlider, since this is real-time data.  I believe or have read that if the start and endTime extent are set to the same time, then it should be set for a time instant which I have since data is added in real-time.  Let me know if you see anything that I don't have set-up correctly.  I have looked at the time formats as well for gps_time and all seems to be correct in this format: Thu Jul 16 2015 11:38:54 GMT-0600 (MDT)

Thanks!  - Carisa

Some of the renderer code.. trying to keep it as simple as possible just to get this working for now:

var simplerMarker = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE,12,new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,

        new Color("red"), 1),

        new Color("red"));

        var observationRend = new UniqueValueRenderer(simplerMarker,"group");

        observationRend.addValue("SolidWaste",new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE,10,new SimpleLineSymbol(SimpleLineSymbol.STYLE_NULL),new Color([255, 153, 0])));

        observationRend.addValue("StormSweeper",new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE,10,new SimpleLineSymbol(SimpleLineSymbol.STYLE_NULL),new Color([9, 112, 84])));

        var infos = [

        { minAge: 0, maxAge: 15, size: 15},

        { minAge: 15, maxAge: 24, size: 11},

        { minAge: 24, maxAge: Infinity, size: 6}

        ];

        var observationAger = new TimeClassBreaksAger(infos, TimeClassBreaksAger.UNIT_SECONDS);

        rendererBC = new TemporalRenderer(observationRend,null,null,observationAger);

Then I'll set the map's time extent since I'm not using a Time Slider:

          var timeExtent = new TimeExtent();

          var now = new Date();

          timeExtent.startTime = now;

          timeExtent.endTime = now;

          map.setTimeExtent(timeExtent);

Feature Collection object set-up for the Feature Layer:

                //Create Feature Layer for Vehicles

                var featureCollection = {

                  "layerDefinition": null,

                  "featureSet": {

                    "features": [],

                    "geometryType": "esriGeometryPoint"

                  }

                };

                        featureCollection.layerDefinition = {

                          "geometryType": "esriGeometryPoint",

                          "objectIdField": "OBJECTID",

                          "timeInfo": {

                            "startTimeField": "gps_date",

                            "endTimeField": null,

                            "trackIdField": "unit_id",

                            "timeReference": "Mountain Standard Time",  //do I need to set this?

                            "timeInterval": 15,

                            "timeExtent": ["2015/07/16 00:00:00 UTC", "2015/07/16 00:00:00 UTC"],

                            "timeIntervalUnits": "esriTimeUnitsSeconds",

                            "exportOptions": {

                             "useTime": true,

                             "timeDataCumulative": true,

                             "timeOffset": null,

                             "timeOffsetUnits": null

                            },

                           },

                          "fields": [{

                            "name": "OBJECTID",

                            "alias": "OBJECTID",

                            "type": "esriFieldTypeOID"

                          }, {

                            "name": "unit_id",

                            "alias": "unit_id",

                            "type": "esriFieldTypeString"

                          }, {

                            "name": "gps_date",

                            "alias": "gps_date",

                            "type": "esriFieldTypeDate"

                          }, {....etc.

                    breadcrumbLayer = new FeatureLayer(featureCollection, {

                          id: 'breadcrumb',

                          mode: FeatureLayer.MODE_SNAPSHOT,

                          trackIdField: "unit_id",

                          outFields: ["*"]

                        });

                      //render a particular time extent - do I need this??

                      var timeExtent = new TimeExtent();

                      timeExtent.startTime = new Date("07/16/2015 UTC");

                      timeExtent.endTime = new Date("07/16/2015 UTC");

                      breadcrumbLayer.setTimeDefinition(timeExtent);

0 Kudos
1 Solution

Accepted Solutions
CarisaSmith
Deactivated User

Finally!!   Ok, I believe my issue was partially date issues with my dates being MST (new Date()).toLocaleString(); and not matching up with the map's TimeExtent of just new Date().  Plus, I had other features based on a different date field for historic uses that I'll have to figure out how to handle that.  And mainly, that I wasn't updating the map's endTime for it's TimeExtent after each new breadcrumb add.  I tried that before but didn't have my dates sorted out then.

This is needed for sure:

featureLayer.applyEdits([graphic], null, null, function (adds){ map.setTimeExtent(new TimeExtent(null, new Date()));});

This example does work in google Chrome on the iPhone, except this portion can be commented out for the timeInfo on the Feature Collection object:

"timeExtent": [1277412330365],

Geolocation with a temporal renderer | ArcGIS API for JavaScript

Hopefully that helps someone else out with real-time data and the Temporal Renderer.

Carisa

View solution in original post

5 Replies
TomSellsted
MVP Regular Contributor

Carisa,

It looks like your time extent is the same for both start and ending times.  You might try being more specific about the time range using dates and times.

Regards,

Tom

0 Kudos
CarisaSmith
Deactivated User

From here it states to set the extent start and end time the same for an instant in time.  It's the current instant in time.  TimeExtent (legacy) | API Reference | ArcGIS API for JavaScript

and it states: If the startTime is null or undefined the start time is negative infinity. If the endTime is null or undefined the endTime is positive infinity. To represent an instant in time set the startTime and endTime to the same time value.

So, I tried to set the map's time extent to start at the current time and then have an endTime of null and/or undefined, since I do want it open ended and that doesn't help either.  If I set the startTime to 7 days prior and endTime 7 days into the future, I'll get the smaller circle symbols... otherwise, if the endTime is not set or is equal to the startTime, I'll get large circle symbols and they don't ever become small as time passes.

0 Kudos
TomSellsted
MVP Regular Contributor

Carisa,

I have experimented a bit with this using my own vehicle data. When using a map service that is time enabled the ager works properly.  When using a map service that is not time enabled and trying to manually establish time parameters, I am having the same result you are seeing. 

I will try tweaking things a bit more and see if I can come up with what is missing.

Regards,

Tom

0 Kudos
CarisaSmith
Deactivated User

Thanks, Tom!  My historic version works w the same Feature Collection object, so I feel like it's something to do with the Map TimeExtent and that not working w a Feature Collection object... maybe or just not working w real live data in the present time.  Or, some setting is off somewhere.  Let me know if you find anything.  Thanks!

0 Kudos
CarisaSmith
Deactivated User

Finally!!   Ok, I believe my issue was partially date issues with my dates being MST (new Date()).toLocaleString(); and not matching up with the map's TimeExtent of just new Date().  Plus, I had other features based on a different date field for historic uses that I'll have to figure out how to handle that.  And mainly, that I wasn't updating the map's endTime for it's TimeExtent after each new breadcrumb add.  I tried that before but didn't have my dates sorted out then.

This is needed for sure:

featureLayer.applyEdits([graphic], null, null, function (adds){ map.setTimeExtent(new TimeExtent(null, new Date()));});

This example does work in google Chrome on the iPhone, except this portion can be commented out for the timeInfo on the Feature Collection object:

"timeExtent": [1277412330365],

Geolocation with a temporal renderer | ArcGIS API for JavaScript

Hopefully that helps someone else out with real-time data and the Temporal Renderer.

Carisa