Skip to content

Commit

Permalink
Add shape types
Browse files Browse the repository at this point in the history
  • Loading branch information
OS-giulianasilva committed May 8, 2023
1 parent 33e4bd6 commit df7380a
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 45 deletions.
2 changes: 1 addition & 1 deletion src/OSFramework/Maps/Event/Shape/ShapeProviderEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace OSFramework.Maps.Event.Shape {
mapId: string,
shapeId: string,
eventName: string,
args: any
args: OSFramework.Maps.OSStructures.OSMap.OSShapeCoordinates
): void {
this.handlers
.slice(0)
Expand Down
23 changes: 23 additions & 0 deletions src/OSFramework/Maps/OSStructures/OSMap.Coordinates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,27 @@ namespace OSFramework.Maps.OSStructures.OSMap {
this.Lng = lng;
}
}

export type PolylineCoordinates = {
coordinates: Array<OSCoordinates>;
location: Array<string>;
};

export type CircleCoordinates = {
coordinates: OSCoordinates;
location: {
location: string;
radius: number;
};
};

export type RectangleCoordinates = {
coordinates: Bounds;
location: Bounds;
};

export type OSShapeCoordinates =
| PolylineCoordinates // Polyline and Polygon type
| CircleCoordinates
| RectangleCoordinates;
}
6 changes: 3 additions & 3 deletions src/Providers/Maps/Google/DrawingTools/AbstractDrawShape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace Provider.Maps.Google.DrawingTools {
mapId: string,
shapeId: string,
eventName: string,
shapeProperties: any
shapeCoordinates: OSFramework.Maps.OSStructures.OSMap.OSShapeCoordinates
) => {
this.drawingTools.drawingToolsEvents.trigger(
// EventType
Expand All @@ -38,9 +38,9 @@ namespace Provider.Maps.Google.DrawingTools {
{
uniqueId: _shape.uniqueId,
isNewElement: false,
location: JSON.stringify(shapeProperties.location),
location: JSON.stringify(shapeCoordinates.location),
coordinates: JSON.stringify(
shapeProperties.coordinates
shapeCoordinates.coordinates
)
}
);
Expand Down
8 changes: 1 addition & 7 deletions src/Providers/Maps/Google/Shape/Circle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,7 @@ namespace Provider.Maps.Google.Shape {
.CFG_InvalidCircleShapeCenter;
}

protected getShapeProperties(): {
coordinates: OSFramework.Maps.OSStructures.OSMap.OSCoordinates;
location: {
location: string;
radius: number;
};
} {
protected getShapeCoordinates(): OSFramework.Maps.OSStructures.OSMap.CircleCoordinates {
return {
coordinates: {
Lat: this.providerCenter.lat,
Expand Down
5 changes: 1 addition & 4 deletions src/Providers/Maps/Google/Shape/Polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ namespace Provider.Maps.Google.Shape {
});
}

protected getShapeProperties(): {
coordinates: Array<OSFramework.Maps.OSStructures.OSMap.OSCoordinates>;
location: Array<string>;
} {
protected getShapeCoordinates(): OSFramework.Maps.OSStructures.OSMap.PolylineCoordinates {
const locations = this.providerObjectPath
.getArray()
.map((elm) => `${elm.lat()},${elm.lng()}`);
Expand Down
5 changes: 1 addition & 4 deletions src/Providers/Maps/Google/Shape/Polyline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ namespace Provider.Maps.Google.Shape {
});
}

protected getShapeProperties(): {
coordinates: Array<OSFramework.Maps.OSStructures.OSMap.OSCoordinates>;
location: Array<string>;
} {
protected getShapeCoordinates(): OSFramework.Maps.OSStructures.OSMap.PolylineCoordinates {
const locations = this.providerObjectPath
.getArray()
.map((elm) => `${elm.lat()},${elm.lng()}`);
Expand Down
5 changes: 1 addition & 4 deletions src/Providers/Maps/Google/Shape/Rectangle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,7 @@ namespace Provider.Maps.Google.Shape {
});
}

protected getShapeProperties(): {
coordinates: OSFramework.Maps.OSStructures.OSMap.Bounds;
location: OSFramework.Maps.OSStructures.OSMap.Bounds;
} {
protected getShapeCoordinates(): OSFramework.Maps.OSStructures.OSMap.RectangleCoordinates {
const bounds = {
north: this.bounds.north,
south: this.bounds.south,
Expand Down
6 changes: 3 additions & 3 deletions src/Providers/Maps/Leaflet/DrawingTools/AbstractDrawShape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace Provider.Maps.Leaflet.DrawingTools {
mapId: string,
shapeId: string,
eventName: string,
shapeProperties: any
shapeCoordinates: OSFramework.Maps.OSStructures.OSMap.OSShapeCoordinates
) => {
this.drawingTools.drawingToolsEvents.trigger(
// EventType
Expand All @@ -38,9 +38,9 @@ namespace Provider.Maps.Leaflet.DrawingTools {
{
uniqueId: _shape.uniqueId,
isNewElement: false,
location: JSON.stringify(shapeProperties.location),
location: JSON.stringify(shapeCoordinates.location),
coordinates: JSON.stringify(
shapeProperties.coordinates
shapeCoordinates.coordinates
)
}
);
Expand Down
8 changes: 1 addition & 7 deletions src/Providers/Maps/Leaflet/Shape/Circle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,7 @@ namespace Provider.Maps.Leaflet.Shape {
return new L.Circle(center, this.getProviderConfig());
}

protected getShapeProperties(): {
coordinates: OSFramework.Maps.OSStructures.OSMap.OSCoordinates;
location: {
location: string;
radius: number;
};
} {
protected getShapeCoordinates(): OSFramework.Maps.OSStructures.OSMap.CircleCoordinates {
return {
coordinates: {
Lat: this.providerCenter.lat,
Expand Down
5 changes: 1 addition & 4 deletions src/Providers/Maps/Leaflet/Shape/Polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ namespace Provider.Maps.Leaflet.Shape {
return new L.Polygon(path, this.getProviderConfig());
}

protected getShapeProperties(): {
coordinates: Array<OSFramework.Maps.OSStructures.OSMap.OSCoordinates>;
location: Array<string>;
} {
protected getShapeCoordinates(): OSFramework.Maps.OSStructures.OSMap.PolylineCoordinates {
const locations = (this.providerObjectPath as Array<L.LatLng>).map(
(elm) => `${elm.lat},${elm.lng}`
);
Expand Down
5 changes: 1 addition & 4 deletions src/Providers/Maps/Leaflet/Shape/Polyline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ namespace Provider.Maps.Leaflet.Shape {
return new L.Polyline(path, this.getProviderConfig());
}

protected getShapeProperties(): {
coordinates: Array<OSFramework.Maps.OSStructures.OSMap.OSCoordinates>;
location: Array<string>;
} {
protected getShapeCoordinates(): OSFramework.Maps.OSStructures.OSMap.PolylineCoordinates {
const locations = (this.providerObjectPath as Array<L.LatLng>).map(
(elm) => `${elm.lat},${elm.lng}`
);
Expand Down
5 changes: 1 addition & 4 deletions src/Providers/Maps/Leaflet/Shape/Rectangle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,7 @@ namespace Provider.Maps.Leaflet.Shape {
});
}

protected getShapeProperties(): {
coordinates: OSFramework.Maps.OSStructures.OSMap.Bounds;
location: OSFramework.Maps.OSStructures.OSMap.Bounds;
} {
protected getShapeCoordinates(): OSFramework.Maps.OSStructures.OSMap.RectangleCoordinates {
const bounds = {
north: this.bounds.north,
south: this.bounds.south,
Expand Down

0 comments on commit df7380a

Please sign in to comment.