Skip to content

Commit b5099a3

Browse files
committed
Add circle and polygon options
1 parent 6569113 commit b5099a3

File tree

22 files changed

+751
-36
lines changed

22 files changed

+751
-36
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# PHP OpenStreetMap Static API
66

7-
PHP library to easily get static image from OpenStreetMap with markers and lines.
7+
PHP library to easily get static image from OpenStreetMap with markers, lines, circles and polygons.
88

99
This project uses the [Tile Server](https://wiki.openstreetmap.org/wiki/Tile_servers) of the OpenStreetMap Foundation which runs entirely on donated resources, see [Tile Usage Policy](https://operations.osmfoundation.org/policies/tiles/) for more information.
1010

@@ -39,7 +39,7 @@ use \DantSu\OpenStreetMapStaticAPI\Markers;
3939
->addMarker(new LatLng(44.351510, 2.570020))
4040
->addMarker(new LatLng(44.351873, 2.566250))
4141
)
42-
->addLine(
42+
->addDraw(
4343
(new Line('FF0000', 2))
4444
->addPoint(new LatLng(44.351172, 2.571092))
4545
->addPoint(new LatLng(44.352097, 2.570045))
@@ -59,11 +59,13 @@ use \DantSu\OpenStreetMapStaticAPI\Markers;
5959

6060
| Class | Description |
6161
|--- |--- |
62+
| [Circle](./docs/classes/DantSu/OpenStreetMapStaticAPI/Circle.md) | DantSu\OpenStreetMapStaticAPI\Circle draw circle on the map.|
6263
| [LatLng](./docs/classes/DantSu/OpenStreetMapStaticAPI/LatLng.md) | DantSu\OpenStreetMapStaticAPI\LatLng define latitude and longitude for map, lines, markers.|
6364
| [Line](./docs/classes/DantSu/OpenStreetMapStaticAPI/Line.md) | DantSu\OpenStreetMapStaticAPI\Line draw line on the map.|
6465
| [MapData](./docs/classes/DantSu/OpenStreetMapStaticAPI/MapData.md) | DantSu\OpenStreetMapStaticAPI\MapData convert latitude and longitude to image pixel position.|
6566
| [Markers](./docs/classes/DantSu/OpenStreetMapStaticAPI/Markers.md) | DantSu\OpenStreetMapStaticAPI\Markers display markers on the map.|
66-
| [OpenStreetMap](./docs/classes/DantSu/OpenStreetMapStaticAPI/OpenStreetMap.md) | DantSu\OpenStreetMapStaticAPI\BoundingBox define the bounding box of the static map.|
67+
| [OpenStreetMap](./docs/classes/DantSu/OpenStreetMapStaticAPI/OpenStreetMap.md) | DantSu\OpenStreetMapStaticAPI\OpenStreetMap is a PHP library created for easily get static image from OpenStreetMap with markers and lines.|
68+
| [Polygon](./docs/classes/DantSu/OpenStreetMapStaticAPI/Polygon.md) | DantSu\OpenStreetMapStaticAPI\Polygon draw polygon on the map.|
6769
| [XY](./docs/classes/DantSu/OpenStreetMapStaticAPI/XY.md) | DantSu\OpenStreetMapStaticAPI\XY define X and Y pixel position for map, lines, markers.|
6870

6971

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
],
2424
"require": {
2525
"php": ">=7.0",
26-
"dantsu/php-image-editor": "^1.0"
26+
"dantsu/php-image-editor": "^1.1"
2727
},
2828
"autoload": {
2929
"psr-4": {
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
2+
# Circle
3+
4+
DantSu\OpenStreetMapStaticAPI\Circle draw circle on the map.
5+
6+
7+
8+
* Full name: `\DantSu\OpenStreetMapStaticAPI\Circle`
9+
* This class implements: \DantSu\OpenStreetMapStaticAPI\Interfaces\Draw
10+
11+
**See Also:**
12+
13+
* https://github.com/DantSu/php-osm-static-api - Github page of this project
14+
15+
16+
17+
## Methods
18+
19+
- [__construct](#-__construct)
20+
- [setEdgePoint](#-setedgepoint)
21+
- [setRadius](#-setradius)
22+
- [draw](#-draw)
23+
24+
### ->__construct
25+
26+
Circle constructor.
27+
28+
29+
30+
31+
32+
33+
34+
35+
#### Parameters:
36+
37+
| Parameter | Type | Description |
38+
|-----------|------|-------------|
39+
| `center` | **\DantSu\OpenStreetMapStaticAPI\LatLng** | Latitude and longitude of the circle center |
40+
| `strokeColor` | **string** | Hexadecimal string color |
41+
| `strokeWeight` | **int** | pixel weight of the line |
42+
| `fillColor` | **string** | Hexadecimal string color |
43+
44+
45+
46+
47+
---
48+
### ->setEdgePoint
49+
50+
Set a latitude and longitude to define the radius of the circle.
51+
52+
53+
54+
55+
56+
57+
58+
59+
#### Parameters:
60+
61+
| Parameter | Type | Description |
62+
|-----------|------|-------------|
63+
| `edge` | **\DantSu\OpenStreetMapStaticAPI\LatLng** | Latitude and longitude of the edge point of a circle |
64+
65+
66+
#### Return Value:
67+
68+
**$this** : Fluent interface
69+
70+
71+
72+
---
73+
### ->setRadius
74+
75+
Set the radius of the circle in meters.
76+
77+
78+
79+
80+
81+
82+
83+
84+
#### Parameters:
85+
86+
| Parameter | Type | Description |
87+
|-----------|------|-------------|
88+
| `radius` | **float** | radius of a circle in meters |
89+
90+
91+
#### Return Value:
92+
93+
**$this** : Fluent interface
94+
95+
96+
97+
---
98+
### ->draw
99+
100+
Draw the circle on the map image.
101+
102+
103+
104+
105+
106+
107+
108+
109+
#### Parameters:
110+
111+
| Parameter | Type | Description |
112+
|-----------|------|-------------|
113+
| `image` | **\DantSu\PHPImageEditor\Image** | The map image (An instance of DantSu\PHPImageEditor\Image) |
114+
| `mapData` | **\DantSu\OpenStreetMapStaticAPI\MapData** | Bounding box of the map |
115+
116+
117+
#### Return Value:
118+
119+
**$this** : Fluent interface
120+
121+
122+
#### See Also:
123+
124+
* https://github.com/DantSu/php-image-editor - See more about DantSu\PHPImageEditor\Image
125+
126+
---
127+
128+
129+
---
130+
> Automatically generated from source code comments on 2022-05-24 using [phpDocumentor](http://www.phpdoc.org/)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
# Draw
3+
4+
5+
6+
7+
8+
* Full name: `\DantSu\OpenStreetMapStaticAPI\Interfaces\Draw`
9+
* Parent interface: [](../../../../classes.md)
10+
11+
12+
13+
## Methods
14+
15+
### ->draw
16+
17+
18+
19+
20+
21+
22+
23+
24+
25+
26+
#### Parameters:
27+
28+
| Parameter | Type | Description |
29+
|-----------|------|-------------|
30+
| `image` | **\DantSu\PHPImageEditor\Image** | |
31+
| `mapData` | **\DantSu\OpenStreetMapStaticAPI\MapData** | |
32+
33+
34+
#### Return Value:
35+
36+
**mixed** :
37+
38+
39+
40+
---
41+
42+
43+
---
44+
> Automatically generated from source code comments on 2022-05-24 using [phpDocumentor](http://www.phpdoc.org/)

docs/classes/DantSu/OpenStreetMapStaticAPI/LatLng.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,4 @@ Get longitude
8282

8383

8484
---
85-
> Automatically generated from source code comments on 2022-04-07 using [phpDocumentor](http://www.phpdoc.org/)
85+
> Automatically generated from source code comments on 2022-05-24 using [phpDocumentor](http://www.phpdoc.org/)

docs/classes/DantSu/OpenStreetMapStaticAPI/Line.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ DantSu\OpenStreetMapStaticAPI\Line draw line on the map.
66

77

88
* Full name: `\DantSu\OpenStreetMapStaticAPI\Line`
9+
* This class implements: \DantSu\OpenStreetMapStaticAPI\Interfaces\Draw
910

1011
**See Also:**
1112

@@ -98,4 +99,4 @@ Draw the line on the map image.
9899

99100

100101
---
101-
> Automatically generated from source code comments on 2022-04-07 using [phpDocumentor](http://www.phpdoc.org/)
102+
> Automatically generated from source code comments on 2022-05-24 using [phpDocumentor](http://www.phpdoc.org/)

docs/classes/DantSu/OpenStreetMapStaticAPI/MapData.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,4 +379,4 @@ Convert a latitude and longitude to a XY pixel position in the image
379379

380380

381381
---
382-
> Automatically generated from source code comments on 2022-04-07 using [phpDocumentor](http://www.phpdoc.org/)
382+
> Automatically generated from source code comments on 2022-05-24 using [phpDocumentor](http://www.phpdoc.org/)

docs/classes/DantSu/OpenStreetMapStaticAPI/Markers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,4 @@ Draw markers on the image map.
135135

136136

137137
---
138-
> Automatically generated from source code comments on 2022-04-07 using [phpDocumentor](http://www.phpdoc.org/)
138+
> Automatically generated from source code comments on 2022-05-24 using [phpDocumentor](http://www.phpdoc.org/)

docs/classes/DantSu/OpenStreetMapStaticAPI/OpenStreetMap.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ DantSu\OpenStreetMapStaticAPI\OpenStreetMap is a PHP library created for easily
1717

1818
- [__construct](#-__construct)
1919
- [addMarkers](#-addmarkers)
20-
- [addLine](#-addline)
20+
- [addDraw](#-adddraw)
2121
- [getMapData](#-getmapdata)
2222
- [getImage](#-getimage)
2323

@@ -70,7 +70,7 @@ Add markers on the map
7070

7171

7272
---
73-
### ->addLine
73+
### ->addDraw
7474

7575
Add a line on the map
7676

@@ -85,7 +85,7 @@ Add a line on the map
8585

8686
| Parameter | Type | Description |
8787
|-----------|------|-------------|
88-
| `line` | **\DantSu\OpenStreetMapStaticAPI\Line** | An instance of Line |
88+
| `draw` | **\DantSu\OpenStreetMapStaticAPI\Interfaces\Draw** | An instance of Line |
8989

9090

9191
#### Return Value:
@@ -142,4 +142,4 @@ Get the map image with markers and lines.
142142

143143

144144
---
145-
> Automatically generated from source code comments on 2022-04-07 using [phpDocumentor](http://www.phpdoc.org/)
145+
> Automatically generated from source code comments on 2022-05-24 using [phpDocumentor](http://www.phpdoc.org/)
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
2+
# Polygon
3+
4+
DantSu\OpenStreetMapStaticAPI\Polygon draw polygon on the map.
5+
6+
7+
8+
* Full name: `\DantSu\OpenStreetMapStaticAPI\Polygon`
9+
* This class implements: \DantSu\OpenStreetMapStaticAPI\Interfaces\Draw
10+
11+
**See Also:**
12+
13+
* https://github.com/DantSu/php-osm-static-api - Github page of this project
14+
15+
16+
17+
## Methods
18+
19+
- [__construct](#-__construct)
20+
- [addPoint](#-addpoint)
21+
- [draw](#-draw)
22+
23+
### ->__construct
24+
25+
Polygon constructor.
26+
27+
28+
29+
30+
31+
32+
33+
34+
#### Parameters:
35+
36+
| Parameter | Type | Description |
37+
|-----------|------|-------------|
38+
| `strokeColor` | **string** | Hexadecimal string color |
39+
| `strokeWeight` | **int** | pixel weight of the line |
40+
| `fillColor` | **string** | Hexadecimal string color |
41+
42+
43+
44+
45+
---
46+
### ->addPoint
47+
48+
Add a latitude and longitude to the polygon
49+
50+
51+
52+
53+
54+
55+
56+
57+
#### Parameters:
58+
59+
| Parameter | Type | Description |
60+
|-----------|------|-------------|
61+
| `latLng` | **\DantSu\OpenStreetMapStaticAPI\LatLng** | Latitude and longitude to add |
62+
63+
64+
#### Return Value:
65+
66+
**$this** : Fluent interface
67+
68+
69+
70+
---
71+
### ->draw
72+
73+
Draw the polygon on the map image.
74+
75+
76+
77+
78+
79+
80+
81+
82+
#### Parameters:
83+
84+
| Parameter | Type | Description |
85+
|-----------|------|-------------|
86+
| `image` | **\DantSu\PHPImageEditor\Image** | The map image (An instance of DantSu\PHPImageEditor\Image) |
87+
| `mapData` | **\DantSu\OpenStreetMapStaticAPI\MapData** | Bounding box of the map |
88+
89+
90+
#### Return Value:
91+
92+
**$this** : Fluent interface
93+
94+
95+
#### See Also:
96+
97+
* https://github.com/DantSu/php-image-editor - See more about DantSu\PHPImageEditor\Image
98+
99+
---
100+
101+
102+
---
103+
> Automatically generated from source code comments on 2022-05-24 using [phpDocumentor](http://www.phpdoc.org/)

0 commit comments

Comments
 (0)