File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed
src/PolylineAlgorithm/Abstraction Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ public Polyline Encode(IEnumerable<TCoordinate> coordinates) {
74
74
75
75
return builder . Build ( ) ;
76
76
77
- static int GetMaximumLength ( int count ) => count > 1 ? count * Defaults . Polyline . MaxEncodedCoordinateLength : int . MaxValue ;
77
+ static int GetMaximumLength ( int count ) => ( count > 1 && count < int . MaxValue / Defaults . Polyline . MaxEncodedCoordinateLength ) ? count * Defaults . Polyline . MaxEncodedCoordinateLength : 64_000 ;
78
78
79
79
static ( int Latitude , int Longitude ) Normalize ( ( double Latitude , double Longitude ) coordinate ) =>
80
80
( PolylineEncoding . Default . Normalize ( coordinate . Latitude ) , PolylineEncoding . Default . Normalize ( coordinate . Longitude ) ) ;
@@ -91,6 +91,8 @@ public Polyline Encode(IEnumerable<TCoordinate> coordinates) {
91
91
[ ExcludeFromCodeCoverage ]
92
92
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
93
93
static int GetCount ( IEnumerable < TCoordinate > coordinates ) => coordinates switch {
94
+ TCoordinate [ ] array => array . Length ,
95
+ List < TCoordinate > list => list . Count ,
94
96
ICollection collection => collection . Count ,
95
97
_ => - 1
96
98
} ;
You can’t perform that action at this time.
0 commit comments