Last change
on this file since 7627 was 7627, checked in by Pieter Naber, 15 years ago |
Added new classes for creating KMLFiles.
|
File size:
1.2 KB
|
Line | |
---|
1 | <?
|
---|
2 | /*
|
---|
3 | * Project: NodeMap2.0
|
---|
4 | * File: KMLHandler.class.php
|
---|
5 | * Purpose: Creating of editing KML files
|
---|
6 | */
|
---|
7 |
|
---|
8 | class KMLFile {
|
---|
9 | final $template = '
|
---|
10 | <?xml version="1.0" encoding="UTF-8"?>
|
---|
11 | <kml xmlns="http://www.opengis.net/kml/2.2">
|
---|
12 | %CONTENT%
|
---|
13 | </kml>';
|
---|
14 |
|
---|
15 | private $KMLPlacemarks = array();
|
---|
16 |
|
---|
17 | /*
|
---|
18 | * Function: __construct (constructor)
|
---|
19 | * Parameters: -
|
---|
20 | * Function: Creating a new KMLFile
|
---|
21 | */
|
---|
22 | function __construct() {
|
---|
23 | }
|
---|
24 |
|
---|
25 | function addPlacemark($name, $description, $xcoordinate, $ycoordinate) {
|
---|
26 | $placemark = new KMLPlacemark();
|
---|
27 | $placemark->setName($name);
|
---|
28 | $placemark->setDescription($description);
|
---|
29 | $placemark->setXCoordinate($xcoordinate);
|
---|
30 | $placemark->setYCoordinate($ycoordinate);
|
---|
31 |
|
---|
32 | $this->KMLPlacemarks[] = $placemark;
|
---|
33 | }
|
---|
34 |
|
---|
35 | function toString() {
|
---|
36 | $toString = $template;
|
---|
37 |
|
---|
38 | $placemarkString = '';
|
---|
39 | $placemarkCount = count($this->KMLPlacemarks);
|
---|
40 | for ($i = 0; $i < $placemarkCount; $i++) {
|
---|
41 | $placemarkString .= $this->KMLPlacemarks->toString();
|
---|
42 | }
|
---|
43 |
|
---|
44 | $toString = preg_replace('%CONTENT%', $placemarkString, $toString);
|
---|
45 |
|
---|
46 | return $toString;
|
---|
47 | }
|
---|
48 |
|
---|
49 | function write(string $filename) {
|
---|
50 | // TODO: Write KMLFile to a KML file
|
---|
51 | }
|
---|
52 | }
|
---|
53 | ?>
|
---|
Note:
See
TracBrowser
for help on using the repository browser.