File tree Expand file tree Collapse file tree 7 files changed +102
-7
lines changed
Expand file tree Collapse file tree 7 files changed +102
-7
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ Adheres to [Semantic Versioning](http://semver.org/).
77## [ 4.1.1] ( https://github.com/ngageoint/simple-features-wkb-ios/releases/tag/4.1.1 ) (TBD)
88
99* sf-ios 4.1.1
10+ * MultiLineString with CircularStrings byte encoding fix to use MultiCurve
1011* Imports cleanup and simplification
1112
1213## [ 4.1.0] ( https://github.com/ngageoint/simple-features-wkb-ios/releases/tag/4.1.0 ) (09-07-2022)
Original file line number Diff line number Diff line change 4545 */
4646+(int ) codeFromGeometryType : (enum SFGeometryType) geometryType andHasZ : (BOOL ) hasZ andHasM : (BOOL ) hasM ;
4747
48+ /* *
49+ * Get the well-known binary writable geometry code from the geometry
50+ *
51+ * @param geometry
52+ * geometry
53+ * @return geometry code
54+ */
55+ +(int ) wkbCodeFromGeometry : (SFGeometry *) geometry ;
56+
57+ /* *
58+ * Get the well-known binary writable geometry type from the geometry
59+ *
60+ * @param geometry
61+ * geometry
62+ * @return geometry type
63+ */
64+ +(enum SFGeometryType) wkbGeometryTypeFromGeometry : (SFGeometry *) geometry ;
65+
4866/* *
4967 * Get the Geometry Type from the code
5068 *
Original file line number Diff line number Diff line change 77//
88
99#import " SFWBGeometryCodes.h"
10+ #import " SFLineString.h"
11+ #import " SFCircularString.h"
12+ #import " SFMultiLineString.h"
1013
1114@implementation SFWBGeometryCodes
1215
@@ -91,6 +94,29 @@ +(int) codeFromGeometryType: (enum SFGeometryType) geometryType{
9194 return code;
9295}
9396
97+ +(int ) wkbCodeFromGeometry : (SFGeometry *) geometry {
98+ return [self codeFromGeometryType: [self wkbGeometryTypeFromGeometry: geometry] andHasZ: geometry.hasZ andHasM: geometry.hasM];
99+ }
100+
101+ +(enum SFGeometryType) wkbGeometryTypeFromGeometry : (SFGeometry *) geometry {
102+ enum SFGeometryType type = geometry.geometryType ;
103+ if (![geometry isEmpty ]){
104+ switch (type){
105+ case SF_MULTILINESTRING:
106+ {
107+ SFLineString *lineString = [((SFMultiLineString *) geometry) lineStringAtIndex: 0 ];
108+ if ([lineString isKindOfClass: [SFCircularString class ]]){
109+ type = SF_MULTICURVE;
110+ }
111+ }
112+ break ;
113+ default :
114+ break ;
115+ }
116+ }
117+ return type;
118+ }
119+
94120+(enum SFGeometryType) geometryTypeFromCode : (int ) code {
95121
96122 // Look at the last 2 digits to find the geometry type code
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ -(void) write: (SFGeometry *) geometry{
7979 [_writer writeByte: byteOrder];
8080
8181 // Write the geometry type integer
82- [self writeInt: [SFWBGeometryCodes codeFromGeometry : geometry]];
82+ [self writeInt: [SFWBGeometryCodes wkbCodeFromGeometry : geometry]];
8383
8484 enum SFGeometryType geometryType = geometry.geometryType ;
8585
@@ -97,14 +97,8 @@ -(void) write: (SFGeometry *) geometry{
9797 [self writePolygon: (SFPolygon *)geometry];
9898 break ;
9999 case SF_MULTIPOINT:
100- [self writeMultiPoint: (SFMultiPoint *)geometry];
101- break ;
102100 case SF_MULTILINESTRING:
103- [self writeMultiLineString: (SFMultiLineString *)geometry];
104- break ;
105101 case SF_MULTIPOLYGON:
106- [self writeMultiPolygon: (SFMultiPolygon *)geometry];
107- break ;
108102 case SF_GEOMETRYCOLLECTION:
109103 case SF_MULTICURVE:
110104 case SF_MULTISURFACE:
Original file line number Diff line number Diff line change 117117
118118+(SFLineString *) createLineStringWithHasZ : (BOOL ) hasZ andHasM : (BOOL ) hasM andRing : (BOOL ) ring ;
119119
120+ +(SFCircularString *) createCircularStringWithHasZ : (BOOL ) hasZ andHasM : (BOOL ) hasM ;
121+
122+ +(SFCircularString *) createCircularStringWithHasZ : (BOOL ) hasZ andHasM : (BOOL ) hasM andClosed : (BOOL ) closed ;
123+
120124+(SFPolygon *) createPolygonWithHasZ : (BOOL ) hasZ andHasM : (BOOL ) hasM ;
121125
122126+(SFMultiPoint *) createMultiPointWithHasZ : (BOOL ) hasZ andHasM : (BOOL ) hasM ;
123127
124128+(SFMultiLineString *) createMultiLineStringWithHasZ : (BOOL ) hasZ andHasM : (BOOL ) hasM ;
125129
130+ +(SFMultiLineString *) createMultiLineStringOfCircularStringsWithHasZ : (BOOL ) hasZ andHasM : (BOOL ) hasM ;
131+
126132+(SFMultiPolygon *) createMultiPolygonWithHasZ : (BOOL ) hasZ andHasM : (BOOL ) hasM ;
127133
128134+(SFGeometryCollection *) createGeometryCollectionWithHasZ : (BOOL ) hasZ andHasM : (BOOL ) hasM ;
Original file line number Diff line number Diff line change @@ -465,6 +465,27 @@ +(SFLineString *) createLineStringWithHasZ: (BOOL) hasZ andHasM: (BOOL) hasM and
465465 return lineString;
466466}
467467
468+ +(SFCircularString *) createCircularStringWithHasZ : (BOOL ) hasZ andHasM : (BOOL ) hasM {
469+ return [self createCircularStringWithHasZ: hasZ andHasM: hasM andClosed: false ];
470+ }
471+
472+ +(SFCircularString *) createCircularStringWithHasZ : (BOOL ) hasZ andHasM : (BOOL ) hasM andClosed : (BOOL ) closed {
473+
474+ SFCircularString *circularString = [SFCircularString circularStringWithHasZ: hasZ andHasM: hasM];
475+
476+ int num = 2 + [SFWBTestUtils randomIntLessThan: 9 ];
477+
478+ for (int i = 0 ; i < num; i++){
479+ [circularString addPoint: [self createPointWithHasZ: hasZ andHasM: hasM]];
480+ }
481+
482+ if (closed){
483+ [circularString addPoint: [circularString.points objectAtIndex: 0 ]];
484+ }
485+
486+ return circularString;
487+ }
488+
468489+(SFPolygon *) createPolygonWithHasZ : (BOOL ) hasZ andHasM : (BOOL ) hasM {
469490
470491 SFPolygon *polygon = [SFPolygon polygonWithHasZ: hasZ andHasM: hasM];
@@ -504,6 +525,19 @@ +(SFMultiLineString *) createMultiLineStringWithHasZ: (BOOL) hasZ andHasM: (BOOL
504525 return multiLineString;
505526}
506527
528+ +(SFMultiLineString *) createMultiLineStringOfCircularStringsWithHasZ : (BOOL ) hasZ andHasM : (BOOL ) hasM {
529+
530+ SFMultiLineString *multiLineString = [SFMultiLineString multiLineStringWithHasZ: hasZ andHasM: hasM];
531+
532+ int num = 1 + [SFWBTestUtils randomIntLessThan: 5 ];
533+
534+ for (int i = 0 ; i < num; i++){
535+ [multiLineString addLineString: [self createCircularStringWithHasZ: hasZ andHasM: hasM]];
536+ }
537+
538+ return multiLineString;
539+ }
540+
507541+(SFMultiPolygon *) createMultiPolygonWithHasZ : (BOOL ) hasZ andHasM : (BOOL ) hasM {
508542
509543 SFMultiPolygon *multiPolygon = [SFMultiPolygon multiPolygonWithHasZ: hasZ andHasM: hasM];
Original file line number Diff line number Diff line change @@ -70,6 +70,22 @@ -(void) testMultiLineString {
7070 }
7171}
7272
73+ -(void ) testMultiLineStringWithCircularStrings {
74+
75+ for (int i = 0 ; i < GEOMETRIES_PER_TEST; i++) {
76+
77+ SFMultiLineString *multiLineString = [SFWBGeometryTestUtils createMultiLineStringOfCircularStringsWithHasZ: [SFWBTestUtils coinFlip ] andHasM: [SFWBTestUtils coinFlip ]];
78+
79+ NSData *data = [SFWBGeometryTestUtils writeDataWithGeometry: multiLineString];
80+
81+ SFGeometryCollection *geometry = [SFGeometryCollection geometryCollectionWithGeometries: multiLineString.geometries];
82+
83+ SFGeometry *geometry2 = [SFWBGeometryTestUtils readGeometryWithData: data];
84+
85+ [self geometryTester: geometry withCompare: geometry2];
86+ }
87+ }
88+
7389-(void ) testMultiCurveWithLineStrings {
7490
7591 // Test a pre-created WKB saved as the abstract MultiCurve type with
You can’t perform that action at this time.
0 commit comments