Hi Gabriel,
It seems in the Temporal Schema ISO 19108 doc that we have the following
Values for relative positions
(for the case if both TM_Primitive are TM_Instants)
the operation shall return a value for TM_RelativePosition as follows:
Returns : if:
BEFORE self.position < other.position
EQUALS self.position = other.position
AFTER self.position > other.position
Then in your compareTo method the object referenced by
"TemporalPrimitive that " is corresponding to "other" position, your
method should return 1 for AFTER value and -1 for BEFORE value.
Regards.
Med
Gabriel Roldan a écrit :
> Hi Martin,
>
> I found what I guess is a bug in the temporal module but I'm not sure if
> it actually is or it just seems counter intuitive to me but its correct.
> The thing is with the compareTo implementation in
> DefaultTemporalPrimitive, which seems to return inverted values for
> AFTER and BEFORE.
> I got to this while working with a TreeSet<TemporalGeometricPrimitive>
> which returned an iterator in the reverse order I expected.
>
> As to reproduce:
> Date time1 = new Date(1000L);
> Date time2 = new Date(0L);
> Date time3 = new Date(2000L);
> SortedSet<TemporalGeometricPrimitive> temporalSubset = new
> TreeMap<TemporalGeometricPrimitive>();
> temporalSubset.add(new DefaultInstant(new DefaultPosition(time1)));
> temporalSubset.add(new DefaultInstant(new DefaultPosition(time2)));
> temporalSubset.add(new DefaultInstant(new DefaultPosition(time3)));
>
> Iterator<TemporalGeometricPrimitive> iterator =
> temporalSubset.iterator();
> TemporalGeometricPrimitive t1 = iterator.next();
> TemporalGeometricPrimitive t2 = iterator.next();
> TemporalGeometricPrimitive t3 = iterator.next();
> assertEquals(0L, ((Instant)t1).getPosition().getDate().getTime());
> assertEquals(1000L,
> ((Instant)t2).getPosition().getDate().getTime());
> assertEquals(2000L,
> ((Instant)t3).getPosition().getDate().getTime());
>
> The above last three lines fail because they came as 2000, 1000, 0,
> which makes sense if my interpretation of
> DefaultTemporalPrimitive.compareTo is correct:
>
> public int compareTo(TemporalPrimitive that) {
> if (that==null)
> throw new IllegalArgumentException("Provided temporal object
> is null");
> final RelativePosition pos= this.relativePosition(that);
> if(pos==null)
> throw new ClassCastException("The provided object cannot be
> compared to this one");
> if(pos==RelativePosition.AFTER)
> return -1;
> if(pos==RelativePosition.BEFORE)
> return +1;
>
> if(pos==RelativePosition.EQUALS)
> return 0;
>
> It seems that the return of 1 and -1 is inverted? Like if
> this.relativePosition(that) == AFTER it should return 1 instead of -1?
>
> The other posibility is that the natural order of temporal primitives is
> backward, so just a confirmation would satisfy my curiosity :)
>
> cheers,
>
> Gabriel
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Geotools-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-devel
>
>
>
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel