Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CZML can't reference position with intervals #4915

Closed
emackey opened this issue Jan 24, 2017 · 2 comments
Closed

CZML can't reference position with intervals #4915

emackey opened this issue Jan 24, 2017 · 2 comments

Comments

@emackey
Copy link
Contributor

emackey commented Jan 24, 2017

If one entity has a composite position (a position using time intervals), and another entity attempts to reference that position, the render loop throws. Here's some CZML:

[
  {
    "id":"document",
    "version":"1.0",
    "clock":{
      "interval":"2017-01-05T11:00:00Z/2017-01-05T11:59:59Z",
      "currentTime":"2017-01-05T11:29:59.5Z",
      "multiplier":60,
      "range":"LOOP_STOP"
    }
  },
  {
    "id":"Test Reference Object",
    "availability":"2017-01-05T11:00:00Z/2017-01-05T11:59:59Z",
    "name":"Test Reference Object",
    "path":{
      "show":true,
      "width":2,
      "resolution":300,
      "leadTime":0,
      "trailTime":172800,
      "material":{
        "solidColor":{
          "color":{
            "rgba":[
              255,255,0,255
            ]
          }
        }
      }
    },
    "position":{
      "reference":"Test Main Object#position"
    }
  },
  {
    "id":"Test Main Object",
    "availability":"2017-01-05T11:00:00Z/2017-01-05T11:59:59Z",
    "name":"Test Main Object",
    "label":{
      "text":"Test Main Object",
      "font":"bold 32px \"Droid Sans\",sans-serif",
      "style":"FILL_AND_OUTLINE",
      "scale":0.5,
      "pixelOffset":{
        "cartesian2":[
          5,0
        ]
      },
      "horizontalOrigin":"LEFT",
      "verticalOrigin":"CENTER",
      "fillColor":{
        "rgba":[
          255,255,0,255
        ]
      },
      "outlineColor":{
        "rgba":[
          0,0,0,255
        ]
      },
      "outlineWidth":2.4
    },
    "point":{
      "pixelSize":7,
      "color":{
        "rgba":[
          255,255,0,255
        ]
      }
    },
    "position":[
      {
        "interval":"2017-01-05T11:00:00Z/2017-01-05T11:59:59Z",
        "interpolationAlgorithm":"LAGRANGE",
        "interpolationDegree":5,
        "referenceFrame":"INERTIAL",
        "epoch":"2017-01-05T11:00:00Z",
        "cartesian":[
          0,10775966.0,-40747218.0,-86707.0,
          3599,20984737.0,-36550703.0,-135028.0
        ]
      }
    ]
  }
]

The error thrown is:

TypeError: Cannot read property 'length' of undefined
    at subSampleCompositeProperty (http://c1200610-00.stk.com/Cesium/Source/DataSources/PathVisualizer.js:208:38)
    at reallySubSample (http://c1200610-00.stk.com/Cesium/Source/DataSources/PathVisualizer.js:246:21)
    at subSample (http://c1200610-00.stk.com/Cesium/Source/DataSources/PathVisualizer.js:263:22)
    at PolylineUpdater.updateObject (http://c1200610-00.stk.com/Cesium/Source/DataSources/PathVisualizer.js:369:30)
    at PathVisualizer.update (http://c1200610-00.stk.com/Cesium/Source/DataSources/PathVisualizer.js:472:32)
    at DataSourceDisplay.update (http://c1200610-00.stk.com/Cesium/Source/DataSources/DataSourceDisplay.js:260:41)
    at Viewer._onTick (http://c1200610-00.stk.com/Cesium/Source/Widgets/Viewer/Viewer.js:1483:49)
    at Event.raiseEvent (http://c1200610-00.stk.com/Cesium/Source/Core/Event.js:147:30)
    at Clock.tick (http://c1200610-00.stk.com/Cesium/Source/Core/Clock.js:309:21)
    at CesiumWidget.render (http://c1200610-00.stk.com/Cesium/Source/Widgets/CesiumWidget/CesiumWidget.js:681:43)

To work around this, copy the position block from the main entity above, and replace the position reference in the other entity with a copy-and-paste of the main position block. Then the CZML will work fine. But, there's no easy way to tell the STK Components CZML writer to use this workaround.

@emackey
Copy link
Contributor Author

emackey commented Jan 24, 2017

From my point of view at least, this is a priority 😄

@mramato
Copy link
Contributor

mramato commented Jan 25, 2017

The fix for this should be trivial, the problem is in reallySubSample in PathVisualizer.js, it unwraps the inner property but then tries to sample the ReferneceProperty instead of the unwrapped property. However, there are dragons here and I found at least 2 other path bugs (one is kind of tricky) while looking at this. I'll see what I can do.

mramato added a commit that referenced this issue Jan 25, 2017
…perties.

Fixes #4915

There were several bugs here:

1. `PathVisualizer` was unwrapping a `ReferenceProperty`, finding a
`CompositePositionProperty` inside, and then using the reference as if
it was a composite instead of using the inner property.
2. Same was 1, but for `TimeIntervalCollectionPositionProperty`
3. We were unwrapping `ScaledPositionProperty` and using the inner property
directly, but this prevented the value from actually being scaled properly.
Now we use the `ScaledPositionProperty` which means it falls back to a
generic sampling path but that's the best solution. (Not to mention that
ScaledPositionProperty is privat and will eventually go away).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants