source: trunk/src/class/KMLFile.class.php@ 7628

Last change on this file since 7628 was 7628, checked in by Pieter Naber, 15 years ago

Added some contraints, created a index file for a simple test.

File size: 1.3 KB
Line 
1<?
2/*
3 * Project: NodeMap2.0
4 * File: KMLHandler.class.php
5 * Purpose: Creating of editing KML files
6 */
7
8class 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(KMLPlacemark $placemark) {
26 $this->KMLPlacemarks[] = $placemark;
27 }
28
29 function addPlacemark(string $name, string $description, float $xcoordinate, float $ycoordinate) {
30 $placemark = new KMLPlacemark();
31 $placemark->setName($name);
32 $placemark->setDescription($description);
33 $placemark->setXCoordinate($xcoordinate);
34 $placemark->setYCoordinate($ycoordinate);
35
36 $this->KMLPlacemarks[] = $placemark;
37 }
38
39 function toString() {
40 $toString = $template;
41
42 $placemarkString = '';
43 $placemarkCount = count($this->KMLPlacemarks);
44 for ($i = 0; $i < $placemarkCount; $i++) {
45 $placemarkString .= $this->KMLPlacemarks->toString();
46 }
47
48 $toString = preg_replace('%CONTENT%', $placemarkString, $toString);
49
50 return $toString;
51 }
52
53 function write(string $filename) {
54 // TODO: Write KMLFile to a KML file
55 }
56}
57?>
Note: See TracBrowser for help on using the repository browser.