@@ -671,7 +671,6 @@ define([
671
671
}
672
672
673
673
var packedLength ;
674
- var isSampled ;
675
674
var unwrappedInterval ;
676
675
var unwrappedIntervalLength ;
677
676
@@ -684,18 +683,31 @@ define([
684
683
var isValue = ! defined ( packetData . reference ) && ! defined ( packetData . velocityReference ) ;
685
684
var hasInterval = defined ( combinedInterval ) && ! combinedInterval . equals ( Iso8601 . MAXIMUM_INTERVAL ) ;
686
685
686
+ if ( packetData . delete === true ) {
687
+ // If deleting this property for all time, we can simply set to undefined and return.
688
+ if ( ! hasInterval ) {
689
+ object [ propertyName ] = undefined ;
690
+ return ;
691
+ }
692
+
693
+ // Deleting depends on the type of property we have.
694
+ return removePropertyData ( object [ propertyName ] , combinedInterval ) ;
695
+ }
696
+
697
+ var isSampled = false ;
698
+
687
699
if ( isValue ) {
688
700
unwrappedInterval = unwrapInterval ( type , packetData , sourceUri ) ;
689
701
packedLength = defaultValue ( type . packedLength , 1 ) ;
690
702
unwrappedIntervalLength = defaultValue ( unwrappedInterval . length , 1 ) ;
691
703
isSampled = ! defined ( packetData . array ) && ( typeof unwrappedInterval !== 'string' ) && ( unwrappedIntervalLength > packedLength ) && ( type !== Object ) ;
692
704
}
693
705
694
- //Rotation is a special case because it represents a native type (Number)
695
- //and therefore does not need to be unpacked when loaded as a constant value.
706
+ // Rotation is a special case because it represents a native type (Number)
707
+ // and therefore does not need to be unpacked when loaded as a constant value.
696
708
var needsUnpacking = typeof type . unpack === 'function' && type !== Rotation ;
697
709
698
- //Any time a constant value is assigned, it completely blows away anything else.
710
+ // Any time a constant value is assigned, it completely blows away anything else.
699
711
if ( ! isSampled && ! hasInterval ) {
700
712
if ( isValue ) {
701
713
object [ propertyName ] = new ConstantProperty ( needsUnpacking ? type . unpack ( unwrappedInterval , 0 ) : unwrappedInterval ) ;
@@ -713,8 +725,8 @@ define([
713
725
epoch = JulianDate . fromIso8601 ( packetEpoch ) ;
714
726
}
715
727
716
- //Without an interval, any sampled value is infinite, meaning it completely
717
- //replaces any non-sampled property that may exist.
728
+ // Without an interval, any sampled value is infinite, meaning it completely
729
+ // replaces any non-sampled property that may exist.
718
730
if ( isSampled && ! hasInterval ) {
719
731
if ( ! ( property instanceof SampledProperty ) ) {
720
732
property = new SampledProperty ( type ) ;
@@ -727,19 +739,19 @@ define([
727
739
728
740
var interval ;
729
741
730
- //A constant value with an interval is normally part of a TimeIntervalCollection,
731
- //However, if the current property is not a time-interval collection, we need
732
- //to turn it into a Composite, preserving the old data with the new interval.
742
+ // A constant value with an interval is normally part of a TimeIntervalCollection,
743
+ // However, if the current property is not a time-interval collection, we need
744
+ // to turn it into a Composite, preserving the old data with the new interval.
733
745
if ( ! isSampled && hasInterval ) {
734
- //Create a new interval for the constant value.
746
+ // Create a new interval for the constant value.
735
747
combinedInterval = combinedInterval . clone ( ) ;
736
748
if ( isValue ) {
737
749
combinedInterval . data = needsUnpacking ? type . unpack ( unwrappedInterval , 0 ) : unwrappedInterval ;
738
750
} else {
739
751
combinedInterval . data = createSpecializedProperty ( type , entityCollection , packetData ) ;
740
752
}
741
753
742
- //If no property exists, simply use a new interval collection
754
+ // If no property exists, simply use a new interval collection
743
755
if ( ! defined ( property ) ) {
744
756
if ( isValue ) {
745
757
property = new TimeIntervalCollectionProperty ( ) ;
@@ -750,29 +762,28 @@ define([
750
762
}
751
763
752
764
if ( isValue && property instanceof TimeIntervalCollectionProperty ) {
753
- //If we create a collection, or it already existed, use it.
765
+ // If we create a collection, or it already existed, use it.
754
766
property . intervals . addInterval ( combinedInterval ) ;
755
767
} else if ( property instanceof CompositeProperty ) {
756
- //If the collection was already a CompositeProperty, use it.
768
+ // If the collection was already a CompositeProperty, use it.
757
769
if ( isValue ) {
758
770
combinedInterval . data = new ConstantProperty ( combinedInterval . data ) ;
759
771
}
760
772
property . intervals . addInterval ( combinedInterval ) ;
761
773
} else {
762
- //Otherwise, create a CompositeProperty but preserve the existing data.
763
-
764
- //Put the old property in an infinite interval.
774
+ // Otherwise, create a CompositeProperty but preserve the existing data.
775
+ // Put the old property in an infinite interval.
765
776
interval = Iso8601 . MAXIMUM_INTERVAL . clone ( ) ;
766
777
interval . data = property ;
767
778
768
- //Create the composite.
779
+ // Create the composite.
769
780
property = new CompositeProperty ( ) ;
770
781
object [ propertyName ] = property ;
771
782
772
- //add the old property interval
783
+ // Add the old property interval.
773
784
property . intervals . addInterval ( interval ) ;
774
785
775
- //Change the new data to a ConstantProperty and add it.
786
+ // Change the new data to a ConstantProperty and add it.
776
787
if ( isValue ) {
777
788
combinedInterval . data = new ConstantProperty ( combinedInterval . data ) ;
778
789
}
@@ -788,25 +799,25 @@ define([
788
799
object [ propertyName ] = property ;
789
800
}
790
801
791
- //create a CompositeProperty but preserve the existing data.
802
+ // Create a CompositeProperty but preserve the existing data.
792
803
if ( ! ( property instanceof CompositeProperty ) ) {
793
- //Put the old property in an infinite interval.
804
+ // Put the old property in an infinite interval.
794
805
interval = Iso8601 . MAXIMUM_INTERVAL . clone ( ) ;
795
806
interval . data = property ;
796
807
797
- //Create the composite.
808
+ // Create the composite.
798
809
property = new CompositeProperty ( ) ;
799
810
object [ propertyName ] = property ;
800
811
801
- //add the old property interval
812
+ // Add the old property interval.
802
813
property . intervals . addInterval ( interval ) ;
803
814
}
804
815
805
- //Check if the interval already exists in the composite
816
+ // Check if the interval already exists in the composite.
806
817
var intervals = property . intervals ;
807
818
interval = intervals . findInterval ( combinedInterval ) ;
808
819
if ( ! defined ( interval ) || ! ( interval . data instanceof SampledProperty ) ) {
809
- //If not, create a SampledProperty for it.
820
+ // If not, create a SampledProperty for it.
810
821
interval = combinedInterval . clone ( ) ;
811
822
interval . data = new SampledProperty ( type ) ;
812
823
intervals . addInterval ( interval ) ;
@@ -815,6 +826,28 @@ define([
815
826
updateInterpolationSettings ( packetData , interval . data ) ;
816
827
}
817
828
829
+ function removePropertyData ( property , interval ) {
830
+ if ( property instanceof SampledProperty ) {
831
+ property . removeSamples ( interval ) ;
832
+ return ;
833
+ } else if ( property instanceof TimeIntervalCollectionProperty ) {
834
+ property . intervals . removeInterval ( interval ) ;
835
+ return ;
836
+ } else if ( property instanceof CompositeProperty ) {
837
+ var intervals = property . intervals ;
838
+ for ( var i = 0 ; i < intervals . length ; ++ i ) {
839
+ var intersection = TimeInterval . intersect ( intervals . get ( i ) , interval , scratchTimeInterval ) ;
840
+ if ( ! intersection . isEmpty ) {
841
+ // remove data from the contained properties
842
+ removePropertyData ( intersection . data , interval ) ;
843
+ }
844
+ }
845
+ // remove the intervals from the composite
846
+ intervals . removeInterval ( interval ) ;
847
+ return ;
848
+ }
849
+ }
850
+
818
851
function processPacketData ( type , object , propertyName , packetData , interval , sourceUri , entityCollection ) {
819
852
if ( ! defined ( packetData ) ) {
820
853
return ;
@@ -842,15 +875,27 @@ define([
842
875
combinedInterval = constrainedInterval ;
843
876
}
844
877
845
- var referenceFrame ;
846
- var unwrappedInterval ;
847
- var isSampled = false ;
848
- var unwrappedIntervalLength ;
849
878
var numberOfDerivatives = defined ( packetData . cartesianVelocity ) ? 1 : 0 ;
850
879
var packedLength = Cartesian3 . packedLength * ( numberOfDerivatives + 1 ) ;
880
+ var unwrappedInterval ;
881
+ var unwrappedIntervalLength ;
851
882
var isValue = ! defined ( packetData . reference ) ;
852
883
var hasInterval = defined ( combinedInterval ) && ! combinedInterval . equals ( Iso8601 . MAXIMUM_INTERVAL ) ;
853
884
885
+ if ( packetData . delete === true ) {
886
+ // If deleting this property for all time, we can simply set to undefined and return.
887
+ if ( ! hasInterval ) {
888
+ object [ propertyName ] = undefined ;
889
+ return ;
890
+ }
891
+
892
+ // Deleting depends on the type of property we have.
893
+ return removePositionPropertyData ( object [ propertyName ] , combinedInterval ) ;
894
+ }
895
+
896
+ var referenceFrame ;
897
+ var isSampled = false ;
898
+
854
899
if ( isValue ) {
855
900
if ( defined ( packetData . referenceFrame ) ) {
856
901
referenceFrame = ReferenceFrame [ packetData . referenceFrame ] ;
@@ -861,7 +906,7 @@ define([
861
906
isSampled = unwrappedIntervalLength > packedLength ;
862
907
}
863
908
864
- //Any time a constant value is assigned, it completely blows away anything else.
909
+ // Any time a constant value is assigned, it completely blows away anything else.
865
910
if ( ! isSampled && ! hasInterval ) {
866
911
if ( isValue ) {
867
912
object [ propertyName ] = new ConstantPositionProperty ( Cartesian3 . unpack ( unwrappedInterval ) , referenceFrame ) ;
@@ -879,8 +924,8 @@ define([
879
924
epoch = JulianDate . fromIso8601 ( packetEpoch ) ;
880
925
}
881
926
882
- //Without an interval, any sampled value is infinite, meaning it completely
883
- //replaces any non-sampled property that may exist.
927
+ // Without an interval, any sampled value is infinite, meaning it completely
928
+ // replaces any non-sampled property that may exist.
884
929
if ( isSampled && ! hasInterval ) {
885
930
if ( ! ( property instanceof SampledPositionProperty ) || ( defined ( referenceFrame ) && property . referenceFrame !== referenceFrame ) ) {
886
931
property = new SampledPositionProperty ( referenceFrame , numberOfDerivatives ) ;
@@ -893,19 +938,19 @@ define([
893
938
894
939
var interval ;
895
940
896
- //A constant value with an interval is normally part of a TimeIntervalCollection,
897
- //However, if the current property is not a time-interval collection, we need
898
- //to turn it into a Composite, preserving the old data with the new interval.
941
+ // A constant value with an interval is normally part of a TimeIntervalCollection,
942
+ // However, if the current property is not a time-interval collection, we need
943
+ // to turn it into a Composite, preserving the old data with the new interval.
899
944
if ( ! isSampled && hasInterval ) {
900
- //Create a new interval for the constant value.
945
+ // Create a new interval for the constant value.
901
946
combinedInterval = combinedInterval . clone ( ) ;
902
947
if ( isValue ) {
903
948
combinedInterval . data = Cartesian3 . unpack ( unwrappedInterval ) ;
904
949
} else {
905
950
combinedInterval . data = createReferenceProperty ( entityCollection , packetData . reference ) ;
906
951
}
907
952
908
- //If no property exists, simply use a new interval collection
953
+ // If no property exists, simply use a new interval collection
909
954
if ( ! defined ( property ) ) {
910
955
if ( isValue ) {
911
956
property = new TimeIntervalCollectionPositionProperty ( referenceFrame ) ;
@@ -916,29 +961,29 @@ define([
916
961
}
917
962
918
963
if ( isValue && property instanceof TimeIntervalCollectionPositionProperty && ( defined ( referenceFrame ) && property . referenceFrame === referenceFrame ) ) {
919
- //If we create a collection, or it already existed, use it.
964
+ // If we create a collection, or it already existed, use it.
920
965
property . intervals . addInterval ( combinedInterval ) ;
921
966
} else if ( property instanceof CompositePositionProperty ) {
922
- //If the collection was already a CompositePositionProperty, use it.
967
+ // If the collection was already a CompositePositionProperty, use it.
923
968
if ( isValue ) {
924
969
combinedInterval . data = new ConstantPositionProperty ( combinedInterval . data , referenceFrame ) ;
925
970
}
926
971
property . intervals . addInterval ( combinedInterval ) ;
927
972
} else {
928
- //Otherwise, create a CompositePositionProperty but preserve the existing data.
973
+ // Otherwise, create a CompositePositionProperty but preserve the existing data.
929
974
930
- //Put the old property in an infinite interval.
975
+ // Put the old property in an infinite interval.
931
976
interval = Iso8601 . MAXIMUM_INTERVAL . clone ( ) ;
932
977
interval . data = property ;
933
978
934
- //Create the composite.
979
+ // Create the composite.
935
980
property = new CompositePositionProperty ( property . referenceFrame ) ;
936
981
object [ propertyName ] = property ;
937
982
938
- //add the old property interval
983
+ // Add the old property interval.
939
984
property . intervals . addInterval ( interval ) ;
940
985
941
- //Change the new data to a ConstantPositionProperty and add it.
986
+ // Change the new data to a ConstantPositionProperty and add it.
942
987
if ( isValue ) {
943
988
combinedInterval . data = new ConstantPositionProperty ( combinedInterval . data , referenceFrame ) ;
944
989
}
@@ -953,20 +998,20 @@ define([
953
998
property = new CompositePositionProperty ( referenceFrame ) ;
954
999
object [ propertyName ] = property ;
955
1000
} else if ( ! ( property instanceof CompositePositionProperty ) ) {
956
- //create a CompositeProperty but preserve the existing data.
957
- //Put the old property in an infinite interval.
1001
+ // Create a CompositeProperty but preserve the existing data.
1002
+ // Put the old property in an infinite interval.
958
1003
interval = Iso8601 . MAXIMUM_INTERVAL . clone ( ) ;
959
1004
interval . data = property ;
960
1005
961
- //Create the composite.
1006
+ // Create the composite.
962
1007
property = new CompositePositionProperty ( property . referenceFrame ) ;
963
1008
object [ propertyName ] = property ;
964
1009
965
- //add the old property interval
1010
+ // Add the old property interval.
966
1011
property . intervals . addInterval ( interval ) ;
967
1012
}
968
1013
969
- //Check if the interval already exists in the composite
1014
+ //Check if the interval already exists in the composite.
970
1015
var intervals = property . intervals ;
971
1016
interval = intervals . findInterval ( combinedInterval ) ;
972
1017
if ( ! defined ( interval ) || ! ( interval . data instanceof SampledPositionProperty ) || ( defined ( referenceFrame ) && interval . data . referenceFrame !== referenceFrame ) ) {
@@ -979,6 +1024,28 @@ define([
979
1024
updateInterpolationSettings ( packetData , interval . data ) ;
980
1025
}
981
1026
1027
+ function removePositionPropertyData ( property , interval ) {
1028
+ if ( property instanceof SampledPositionProperty ) {
1029
+ property . removeSamples ( interval ) ;
1030
+ return ;
1031
+ } else if ( property instanceof TimeIntervalCollectionPositionProperty ) {
1032
+ property . intervals . removeInterval ( interval ) ;
1033
+ return ;
1034
+ } else if ( property instanceof CompositePositionProperty ) {
1035
+ var intervals = property . intervals ;
1036
+ for ( var i = 0 ; i < intervals . length ; ++ i ) {
1037
+ var intersection = TimeInterval . intersect ( intervals . get ( i ) , interval , scratchTimeInterval ) ;
1038
+ if ( ! intersection . isEmpty ) {
1039
+ // remove data from the contained properties
1040
+ removePositionPropertyData ( intersection . data , interval ) ;
1041
+ }
1042
+ }
1043
+ // remove the intervals from the composite
1044
+ intervals . removeInterval ( interval ) ;
1045
+ return ;
1046
+ }
1047
+ }
1048
+
982
1049
function processPositionPacketData ( object , propertyName , packetData , interval , sourceUri , entityCollection ) {
983
1050
if ( ! defined ( packetData ) ) {
984
1051
return ;
0 commit comments