Menu

#74 Polyline to Polyline Adapter map has wrong values

Pipistrelle 2.1
open
nobody
None
1
2015-08-20
2015-08-17
John Barnes
No

See the attached PolylineAdapter2.PNG for a screenshot showing part of the map generated for a smple test case in which the adaptee has 44 equal length line segments arranged along a straight line and the adapted values are associated with 17 equal length line segments arranged along the same straight line. The coordinates of the starts of the two polylines are the same. The coordinates on the ends of the two polylines are the same.

Adapted.value[0] should be mapped from the whole of adaptee.value[0], value[1] and part of value[2]
Adapted.value[1] should be mapped from the rest of adaptee.value[2], value[3], value[4] and part of value[5]
Adapted.value[2] should be mapped from the rest of adaptee.value[5], value[6], and part of value[7]
...
The calculated Overlap proportion values look wrong. The first one should be 1.0. Pairs of value for the same Source Segment Index should sum to 1.0.

1 Attachments

Discussion

  • John Barnes

    John Barnes - 2015-08-17

    I made these changes to PolylineToPolyline.cs to fix the problem:

    @@ -179,20 +179,26 @@ namespace FluidEarth2.AdaptedOutputs
                         Debug.Assert(nFromFirst != nFromLast);
    
                         if (nFromFirst + 1 == nFromLast)
    
    -                        overlaps.Add(new SourceSegment(nFromFirst, sToLast - sToFirst));
    +                    {
    +                        overlaps.Add(new SourceSegment(nFromFirst, 1.0));
    +                    }
                         else if (nFromFirst + 2 == nFromLast)
                         {
    -                        overlaps.Add(new SourceSegment(nFromFirst, _adapteeCoords[nFromFirst + 1].S - sToFirst));
    -                        overlaps.Add(new SourceSegment(nFromFirst + 1, sToLast - _adapteeCoords[nFromFirst + 1].S));
    +                        overlaps.Add(new SourceSegment(nFromFirst,
    +                            (_adapteeCoords[nFromFirst + 1].S - sToFirst) / (_adapteeCoords[nFromFirst + 1].S - _adapteeCoords[nFromFirst].S)));
    +                        overlaps.Add(new SourceSegment(nFromFirst + 1,
    +                            (sToLast - _adapteeCoords[nFromLast - 1].S) / (_adapteeCoords[nFromLast].S - _adapteeCoords[nFromLast - 1].S)));
                         }
                         else
                         {
    -                        overlaps.Add(new SourceSegment(nFromFirst, _adapteeCoords[nFromFirst + 1].S - sToFirst));
    +                        overlaps.Add(new SourceSegment(nFromFirst,
    +                            (_adapteeCoords[nFromFirst + 1].S - sToFirst) / (_adapteeCoords[nFromFirst + 1].S - _adapteeCoords[nFromFirst].S)));
    
                             for (int m = nFromFirst + 1; m < nFromLast - 1; ++m)
                                 overlaps.Add(new SourceSegment(m, 1.0));
    
    
    -                        overlaps.Add(new SourceSegment(nFromLast - 1, sToLast - _adapteeCoords[nFromLast - 1].S));
    +                        overlaps.Add(new SourceSegment(nFromLast - 1,
    +                            (sToLast - _adapteeCoords[nFromLast - 1].S) / (_adapteeCoords[nFromLast].S - _adapteeCoords[nFromLast - 1].S)));
                         }
    
                         map.Add(overlaps);
    

    The attached screenshot PolylineAdapter3.PNG shows the map generated after these changes.

     
  • John Barnes

    John Barnes - 2015-08-20

    While the above changes give a correct map in cases where all the adaptee polyline segments are the same length, they do not produce a correct map in the general case. I have reverted those changes (revision 705) as revision 707.

     
  • John Barnes

    John Barnes - 2015-08-20

    This change (revision 708) fixes the problem with the map:

    @@ -193,7 +193,7 @@ namespace FluidEarth2.AdaptedOutputs
                             overlaps.Add(new SourceSegment(nFromFirst, _adapteeCoords[nFromFirst + 1].S - sToFirst));
    
                             for (int m = nFromFirst + 1; m < nFromLast - 1; ++m)
    
    -                            overlaps.Add(new SourceSegment(m, 1.0));
    +                            overlaps.Add(new SourceSegment(m, _adapteeCoords[m + 1].S - _adapteeCoords[m].S));
    
                             overlaps.Add(new SourceSegment(nFromLast - 1, sToLast - _adapteeCoords[nFromLast - 1].S));
                         }
    

    The attached file PolylineAdapter6.PNG shows the map values after this change.

     

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB