@@ -540,8 +540,15 @@ private Element edgeToXml( final Link edge, final int sourceSpotID, final int ta
540540 // Link features.
541541 for ( final ExportFeatureProjection < Link > p : linkFeatureProjections )
542542 {
543- final String attName ;
544543 final String origName = p .attributeName ;
544+ /*
545+ * Do not export link features that are common TrackMate features
546+ * and that we already exported above.
547+ */
548+ if ( CommonTrackMateFeatureDeclarations .redundantLinkProjectionKeys .contains ( origName ) )
549+ continue ;
550+
551+ final String attName ;
545552 /*
546553 * If the model to export was imported from a TrackMate or a MaMuT
547554 * file, it will already contain features with the same name that
@@ -634,8 +641,15 @@ private Element spotToXml( final Spot spot )
634641
635642 for (final ExportFeatureProjection < Spot > p : spotFeatureProjections )
636643 {
637- final String attName ;
638644 final String origName = p .attributeName ;
645+ /*
646+ * Do not export spot features that are common TrackMate features
647+ * and that we already exported above.
648+ */
649+ if ( CommonTrackMateFeatureDeclarations .redundantSpotProjectionKeys .contains ( origName ) )
650+ continue ;
651+
652+ final String attName ;
639653 /*
640654 * If the model to export was imported from a TrackMate or a MaMuT
641655 * file, it will already contain features with the same name that
@@ -710,16 +724,33 @@ private < T > void appendFeaturesDeclarationOfClass( final Class< T > clazz, fin
710724 final String classFeatureDeclarationTag )
711725 {
712726 final List < ExportFeatureProjection < T > > projections ;
727+ List < String > redundantFeatures ;
713728 if ( clazz .equals ( Spot .class ) )
729+ {
714730 projections = ( List ) spotFeatureProjections ;
731+ redundantFeatures = CommonTrackMateFeatureDeclarations .redundantSpotProjectionKeys ;
732+ }
715733 else if ( clazz .equals ( Link .class ) )
734+ {
716735 projections = ( List ) linkFeatureProjections ;
736+ redundantFeatures = CommonTrackMateFeatureDeclarations .redundantLinkProjectionKeys ;
737+ }
717738 else
739+ {
718740 projections = Collections .emptyList ();
741+ redundantFeatures = CommonTrackMateFeatureDeclarations .redundantTrackProjectionKeys ;
742+ }
719743
720744 final Element classFeaturesElement = getOrAddChild ( featuresElement , classFeatureDeclarationTag );
721745 for ( final ExportFeatureProjection < T > p : projections )
722746 {
747+ /*
748+ * Do not export features that are common TrackMate features and
749+ * that we already declared.
750+ */
751+ if ( redundantFeatures .contains ( p .attributeName ) )
752+ continue ;
753+
723754 final String isint = ( p .projection instanceof IntFeatureProjection )
724755 ? "true"
725756 : "false" ;
0 commit comments