CSC220 Processing KML coordinates in Php
--D. Thiebaut 14:10, 27 September 2010 (UTC)
The Map on Google-Maps
The URL
- Google MAP URL: http://maps.google.com/maps/mm?q=http://share.abvio.com/8c66/82ec/4c15/b2d6/Walkmeter-Walk-20100829-0750.kml&ie=UTF8&hl=en
The KML File
(you can get a copy of this file in your 220a-xx account by typing getcopy example1.klm)
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>Walkmeter-Walk-20100829-0750.kml</name>
<Style id="currentPathStyle">
<LineStyle>
<color>aaff0000</color>
<width>4</width>
</LineStyle>
</Style>
<Style id="officialPathStyle">
<LineStyle>
<color>888d1baa</color>
<width>4</width>
</LineStyle>
</Style>
<Style id="bestIconStyle">
<IconStyle><Icon><href>http://share.abvio.com/i/iconBest.png</href></Icon>
<hotSpot x="0.5" y="0.0" xunits="fraction" yunits="fraction"/>
</IconStyle>
</Style>
<Style id="medianIconStyle">
<IconStyle><Icon><href>http://share.abvio.com/i/iconMedian.png</href></Icon>
<hotSpot x="0.5" y="0.0" xunits="fraction" yunits="fraction"/>
</IconStyle>
</Style>
<Style id="worstIconStyle">
<IconStyle><Icon><href>http://share.abvio.com/i/iconWorst.png</href></Icon>
<hotSpot x="0.5" y="0.0" xunits="fraction" yunits="fraction"/>
</IconStyle>
</Style>
<Style id="currentIconStyle">
<IconStyle><Icon><href>http://share.abvio.com/i/iconCurrent.png</href></Icon>
<hotSpot x="0.5" y="0.0" xunits="fraction" yunits="fraction"/>
</IconStyle>
</Style>
<Style id="startIconStyle">
<IconStyle><Icon><href>http://share.abvio.com/i/iconStart.png</href></Icon>
<hotSpot x="0.5" y="0.0" xunits="fraction" yunits="fraction"/>
</IconStyle>
</Style>
<Style id="finishIconStyle">
<IconStyle><Icon><href>http://share.abvio.com/i/iconFinish.png</href></Icon>
<hotSpot x="0.5" y="0.0" xunits="fraction" yunits="fraction"/>
</IconStyle>
</Style>
<Style id="mile1IconStyle">
<IconStyle><Icon><href>http://share.abvio.com/i/iconMile1.png</href></Icon>
<hotSpot x="0.5" y="0.0" xunits="fraction" yunits="fraction"/>
</IconStyle>
</Style>
<Style id="mile2IconStyle">
<IconStyle><Icon><href>http://share.abvio.com/i/iconMile2.png</href></Icon>
<hotSpot x="0.5" y="0.0" xunits="fraction" yunits="fraction"/>
</IconStyle>
</Style>
<Style id="mile3IconStyle">
<IconStyle><Icon><href>http://share.abvio.com/i/iconMile3.png</href></Icon>
<hotSpot x="0.5" y="0.0" xunits="fraction" yunits="fraction"/>
</IconStyle>
</Style>
<Style id="mile4IconStyle">
<IconStyle><Icon><href>http://share.abvio.com/i/iconMile4.png</href></Icon>
<hotSpot x="0.5" y="0.0" xunits="fraction" yunits="fraction"/>
</IconStyle>
</Style>
<Style id="mile5IconStyle">
<IconStyle><Icon><href>http://share.abvio.com/i/iconMile5.png</href></Icon>
<hotSpot x="0.5" y="0.0" xunits="fraction" yunits="fraction"/>
</IconStyle>
</Style>
<Style id="mile6IconStyle">
<IconStyle><Icon><href>http://share.abvio.com/i/iconMile6.png</href></Icon>
<hotSpot x="0.5" y="0.0" xunits="fraction" yunits="fraction"/>
</IconStyle>
</Style>
<Style id="mile7IconStyle">
<IconStyle><Icon><href>http://share.abvio.com/i/iconMile7.png</href></Icon>
<hotSpot x="0.5" y="0.0" xunits="fraction" yunits="fraction"/>
</IconStyle>
</Style>
<Style id="mile8IconStyle">
<IconStyle><Icon><href>http://share.abvio.com/i/iconMile8.png</href></Icon>
<hotSpot x="0.5" y="0.0" xunits="fraction" yunits="fraction"/>
</IconStyle>
</Style>
<Style id="mile9IconStyle">
<IconStyle><Icon><href>http://share.abvio.com/i/iconMile9.png</href></Icon>
<hotSpot x="0.5" y="0.0" xunits="fraction" yunits="fraction"/>
</IconStyle>
</Style>
<Style id="mile10IconStyle">
<IconStyle><Icon><href>http://share.abvio.com/i/iconMile10.png</href></Icon>
<hotSpot x="0.5" y="0.0" xunits="fraction" yunits="fraction"/>
</IconStyle>
</Style>
<Style id="mile11IconStyle">
<IconStyle><Icon><href>http://share.abvio.com/i/iconMile11.png</href></Icon>
<hotSpot x="0.5" y="0.0" xunits="fraction" yunits="fraction"/>
</IconStyle>
</Style>
<Style id="mile12IconStyle">
<IconStyle><Icon><href>http://share.abvio.com/i/iconMile12.png</href></Icon>
<hotSpot x="0.5" y="0.0" xunits="fraction" yunits="fraction"/>
</IconStyle>
</Style>
<Style id="mile13IconStyle">
<IconStyle><Icon><href>http://share.abvio.com/i/iconMile13.png</href></Icon>
<hotSpot x="0.5" y="0.0" xunits="fraction" yunits="fraction"/>
</IconStyle>
</Style>
<Style id="mile14IconStyle">
<IconStyle><Icon><href>http://share.abvio.com/i/iconMile14.png</href></Icon>
<hotSpot x="0.5" y="0.0" xunits="fraction" yunits="fraction"/>
</IconStyle>
</Style>
<Style id="mile15IconStyle">
<IconStyle><Icon><href>http://share.abvio.com/i/iconMile15.png</href></Icon>
<hotSpot x="0.5" y="0.0" xunits="fraction" yunits="fraction"/>
</IconStyle>
</Style>
<Folder>
<name>Walk on Aug 29, 2010</name><open>1</open>
<Placemark>
<name>Start 7:50 AM</name>
<styleUrl>#startIconStyle</styleUrl>
<Point>
<coordinates>-72.69459750750001,42.34444296000000</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Finish 9:57 AM - Average 6:04 /mile</name>
<description>walk time 1:31:33, 15.09 miles, climb 1266 feet, stopped time 35:03</description>
<styleUrl>#finishIconStyle</styleUrl>
<Point>
<coordinates>-72.69433810000001,42.34412963333332</coordinates>
</Point>
</Placemark>
<Folder>
<name><![CDATA[Path]]></name>
<open>0</open>
<Placemark>
<name>Segment 1</name>
<styleUrl>#currentPathStyle</styleUrl>
<LineString>
<extrude>0</extrude>
<tessellate>1</tessellate>
<altitudeMode>clampToGround</altitudeMode>
<coordinates>
-72.69459750750001,42.34444296000000
-72.69435600000000,42.34400928333333
-72.69431068333333,42.34405935000000
-72.69446536666666,42.34410188333333
-72.69409073333333,42.34385796666667
-72.69392793333333,42.34376685000000
-72.69364926666667,42.34365636666666
-72.69293845000000,42.34334739999999
-72.69270220000000,42.34304800000000
-72.69264033333334,42.34287956666667
-72.69265161666668,42.34280600000000
-72.69287370000001,42.34265043333333
-72.69309221666667,42.34251263333334
-72.69328463333333,42.34241403333333
-72.69342835000000,42.34232905000000
-72.69359670000000,42.34220988333334
-72.69377464999999,42.34210050000000
-72.69396520000001,42.34200168333333
-72.69419445000000,42.34190578333333
-72.69439651666667,42.34189388333332
-72.69453363333334,42.34204025000000
-72.69470221666667,42.34222191666666
-72.69501901666666,42.34270666666666
-72.69512208333333,42.34282508333334
-72.69521923333333,42.34295003333334
-72.69535713333333,42.34310354999999
-72.70004826666667,42.34706686666667
-72.70039076666667,42.34721068333333
-72.70040193333332,42.34802353333333
-72.70004603333334,42.34826631666667
-72.70003216666667,42.34844831666665
-72.70006055000000,42.34861358333333
-72.70012486666667,42.34883714999999
-72.70057034999999,42.35001076666667
-72.70065013333333,42.35028361666667
-72.70066539999999,42.35041920000000
-72.70064115000000,42.35058378333333
-72.70066571666666,42.35089555000000
-72.70063010000000,42.35107213333334
-72.70058773333334,42.35125246666666
-72.70052341666666,42.35158495000001
-72.70054191666667,42.35180283333334
-72.70063240000000,42.35196524999999
-72.70070461666666,42.35213293333332
-72.70082200000000,42.35230248333334
-72.70081820000000,42.35259526666667
-72.70069698333333,42.35289595000000
-72.70060319999999,42.35306309999999
-72.70052553333333,42.35318728333333
-72.70045236666667,42.35334903333334
-72.70024975000000,42.35365215000000
-72.69987521666667,42.35341293333332
-72.69998873333334,42.35337424999999
-72.70000245000000,42.35308246666666
-72.70003225000001,42.35281251666667
-72.70004636666667,42.35249565000001
-72.69691094999999,42.34897963333334
-72.69636000000000,42.34911533333334
-72.69629678333334,42.34912315000000
-72.68114810000000,42.34346685000000
-72.68061469999999,42.34358916666667
-72.68048043333333,42.34359520000000
-72.68020828333333,42.34339115000000
-72.67990564999999,42.34318990000000
-72.67961505000000,42.34306358333333
-72.67924203333334,42.34280205000000
-72.67841015000000,42.34216268333333
-72.67815285000000,42.34201571666667
-72.67790886666667,42.34182630000001
-72.67772934999999,42.34168103333333
-72.67754696666665,42.34157003333333
-72.67738585000001,42.34146476666666
-72.67725815000000,42.34136406666666
-72.67694204999999,42.34102923333333
-72.67673468333334,42.34084141666667
-72.67650636666667,42.34073821666666
-72.67637113333333,42.34064595000000
-72.67623576666666,42.34054063333333
-72.67609783333334,42.34039210000000
-72.67290683333333,42.33783566666666
-72.67255301666667,42.33762756666667
-72.67175056666667,42.33683993333334
-72.67073196666666,42.33628873333333
-72.67045618333333,42.33614599999999
-72.67011115000000,42.33606608333333
-72.66970526666667,42.33595011666666
-72.66948111666667,42.33591436666667
-72.66924671666668,42.33589933333333
-72.66904663333332,42.33588526666667
-72.66759900000001,42.33575478333334
-72.66717743333334,42.33581406666667
-72.66628953333334,42.33554763333333
-72.66583198333333,42.33563403333333
-72.66564920000000,42.33562325000000
-72.66517888333333,42.33553616666666
-72.66476405000000,42.33557075000000
-72.66430591666666,42.33560983333333
-72.66390875000000,42.33565825000000
-72.66338423333333,42.33559493333334
-72.66300133333334,42.33552143333333
-72.66260355000000,42.33544141666666
-72.66217215000000,42.33532761666667
-72.66163016666667,42.33535691666666
-72.63166800000000,42.32811293333332
-72.63161256666667,42.32849051666667
-72.63162154999999,42.32867533333333
-72.63161671666667,42.32886736666666
-72.63162038333333,42.32900485000000
-72.63159139999999,42.32937884999999
-72.63147993333334,42.32951500000001
-72.63122571666666,42.32971553333334
-72.63114578333334,42.32979166666667
-72.63081313333333,42.32992915000000
-72.63064793333332,42.33003011666667
-72.63052611666667,42.33010810000000
-72.63035061666666,42.33010913333332
-72.63037103333333,42.33016005000000
-72.63010143333332,42.33038203333334
-72.62976639999999,42.33055221666667
-72.62619621666666,42.33266664999999
-72.62598410000000,42.33265526666667
-72.62206645000001,42.33488473333333
-72.62185230000000,42.33510565000000
-72.62138101666666,42.33539043333334
-72.62120608333333,42.33552870000000
-72.62094906666667,42.33576356666667
-72.62018360000000,42.33624011666667
-72.61951965000000,42.33668650000000
-72.59706738333333,42.34197288333333
-72.59702311666666,42.34171761666666
-72.59711465000001,42.34159105000001
-72.59720470000001,42.34147203333334
-72.59720513333333,42.34136066666667
-72.59720045000002,42.34135766666666
</coordinates>
</LineString>
</Placemark>
<Placemark>
<name>Segment 2</name>
<styleUrl>#currentPathStyle</styleUrl>
<LineString>
<extrude>0</extrude>
<tessellate>1</tessellate>
<altitudeMode>clampToGround</altitudeMode>
<coordinates>
-72.59695311000000,42.34171763666667
-72.59734929999999,42.34113221666667
-72.59719101666666,42.34120508333334
-72.59715608333333,42.34122330000000
-72.59726411666666,42.34119318333334
-72.59728355000001,42.34115080000000
-72.59718653333333,42.34121300000000
-72.59713798333334,42.34118019999999
-72.59720653333333,42.34109445000001
-72.59715405000000,42.34123336666666
-72.59703700000000,42.34140533333332
-72.59704803333334,42.34155641666666
-72.59707841666666,42.34169063333334
-72.59707878333333,42.34188756666668
-72.59709070000001,42.34205416666667
-72.59711109999999,42.34223511666667
-72.59713216666667,42.34237338333334
-72.59715366666666,42.34254380000001
-72.59718538333334,42.34269813333334
-72.59722993333334,42.34274518333334
-72.59776898333332,42.34256173333333
-72.59817929999998,42.34250813333333
-72.59855095000000,42.34244871666666
-72.59886253333333,42.34235873333333
-72.59911651666667,42.34228888333334
-72.59936696666666,42.34222328333334
-72.59982391666667,42.34214880000000
-72.60003486666666,42.34211611666667
-72.60059513333334,42.34196976666667
-72.60081718333332,42.34190481666666
-72.60104041666668,42.34184325000000
-72.60125020000001,42.34180164999999
-72.62200146666667,42.33495594999999
-72.62215023333333,42.33484475000000
-72.62233528333333,42.33477766666667
-72.62253855000000,42.33471473333334
-72.62273175000000,42.33461928333333
-72.62288521666666,42.33453915000000
-72.62331931666665,42.33431905000001
-72.62409725000001,42.33396861666667
-72.62436711666666,42.33380025000000
-72.62453306666666,42.33367740000000
-72.62466363333333,42.33356916666666
-72.62482188333334,42.33345936666667
-72.62496658333333,42.33336803333334
-72.62524843333334,42.33322535000001
-72.62750121666667,42.33189226666666
-72.62778261666668,42.33173993333333
-72.62794113333332,42.33165861666667
-72.62810348333335,42.33158151666666
-72.62826989999999,42.33148166666667
-72.62843366666667,42.33136660000000
-72.63222295000000,42.32908758333333
-72.63239928333334,42.32899836666667
-72.63262811666667,42.32891626666666
-72.63287613333334,42.32884783333334
-72.63309443333333,42.32883635000000
-72.63335418333332,42.32877260000000
-72.63334186666665,42.32849670000001
-72.63332525000000,42.32834441666667
-72.63332348333334,42.32819249999999
-72.63331201666666,42.32798429999999
-72.63330133333334,42.32783011666668
-72.63348366666668,42.32779838333332
-72.63367393333333,42.32779976666667
-72.63386850000001,42.32783776666667
-72.63401430000000,42.32792050000000
-72.63414711666667,42.32801561666667
-72.63435168333334,42.32811638333332
-72.63458276666667,42.32818208333333
-72.63477248333334,42.32823655000000
-72.63505998333333,42.32833231666667
-72.63536705000000,42.32837446666667
-72.63559566666666,42.32844245000000
-72.63583943333333,42.32852298333334
-72.63603390000000,42.32858271666667
-72.63626479999999,42.32865731666667
-72.63649260000001,42.32872516666666
-72.63669868333334,42.32880118333335
-72.63685520000001,42.32887195000000
-72.63727383333334,42.32905278333332
-72.63927383333333,42.32969541666666
-72.63959679999999,42.32983071666666
-72.63977296666667,42.32988658333334
-72.63999091666666,42.32996386666667
-72.64021043333334,42.33004131666667
-72.64056258333333,42.33015283333334
-72.64113883333333,42.33036670000000
-72.64994996666665,42.33360675000000
-72.65019310000000,42.33366219999999
-72.65075308333333,42.33375641666667
-72.65099496666667,42.33376511666667
-72.65143636666667,42.33382758333334
-72.65190559999999,42.33400936666667
-72.65242858333333,42.33409260000001
-72.65307020000000,42.33427390000001
-72.65330406666666,42.33434803333333
-72.65395751666667,42.33447826666667
-72.65749456666667,42.33495446666668
-72.65811878333334,42.33500338333333
-72.65838283333332,42.33503795000000
-72.65864155000000,42.33507428333334
-72.65902961666667,42.33513480000000
-72.67208651666667,42.33714480000000
-72.67223855000000,42.33727926666667
-72.67242848333333,42.33743351666666
-72.67415090000000,42.33875796666666
-72.67428095000001,42.33886314999999
-72.67444645000000,42.33900786666667
-72.67455713333334,42.33914156666667
-72.67468016666666,42.33927471666667
-72.67479436666666,42.33938116666667
-72.67491930000000,42.33949676666666
-72.67522134999999,42.33972556666666
-72.68076926666666,42.34326726666666
-72.68091370000000,42.34316051666666
-72.68121309999999,42.34323483333333
-72.68148358333333,42.34324036666667
-72.68171341666667,42.34322471666666
-72.68201585000000,42.34321146666667
-72.68224803333332,42.34323900000000
-72.68242350000000,42.34334135000000
-72.68263441666666,42.34351611666666
-72.68276058333332,42.34364670000000
-72.68287366666667,42.34378149999999
-72.68302396666667,42.34389738333332
-72.68316798333333,42.34399048333333
-72.68335921666666,42.34405190000001
-72.68365300000001,42.34406231666667
-72.68383848333333,42.34408430000000
-72.68451275000001,42.34430311666667
-72.68459490000001,42.34451913333334
-72.68467208333333,42.34465540000000
-72.68483175000000,42.34488443333333
-72.68641021666667,42.34689758333334
-72.68632455000001,42.34702231666667
-72.68641111666668,42.34716601666667
-72.68655523333334,42.34725038333332
-72.68677515000000,42.34737856666668
-72.68694105000000,42.34746055000001
-72.68722088333334,42.34760908333332
-72.68739135000001,42.34770025000000
-72.68754146666667,42.34778800000001
-72.68770111666666,42.34787811666666
-72.68790555000001,42.34799921666666
-72.68810180000000,42.34811041666667
-72.68829136666666,42.34821985000000
-72.68855030000000,42.34838928333333
-72.68876100000000,42.34852715000000
-72.68892968333333,42.34864015000000
-72.68910250000000,42.34874535000000
-72.68925625000000,42.34882938333333
-72.68961718333334,42.34900958333333
-72.69999435000000,42.35145506666666
-72.70004821666667,42.35161981666667
-72.70007746666667,42.35179031666667
-72.70009246666666,42.35195046666666
-72.70020285000000,42.35300266666666
-72.70022121666666,42.35319293333334
-72.70027605000000,42.35348013333333
-72.70036988333334,42.35360226666666
-72.70051378333332,42.35369731666667
-72.70073813333333,42.35373711666666
-72.70088269999999,42.35348628333333
-72.70087498333334,42.35334970000000
-72.70093156666667,42.35028963333333
-72.70093720000000,42.35013996666667
-72.70091049999999,42.34996198333334
-72.70082574999999,42.34978783333333
-72.70034260000000,42.34827640000000
-72.70048210000000,42.34816805000001
-72.70061373333333,42.34799410000000
-72.70061843333333,42.34782919999999
-72.70036616666665,42.34702501666668
-72.69271225000001,42.34235086666666
-72.69267878333333,42.34254801666666
-72.69267330000000,42.34261633333334
-72.69409016666667,42.34391306666667
-72.69424906666666,42.34403235000000
-72.69433810000001,42.34412963333332
-72.69433810000001,42.34412963333332
</coordinates>
</LineString>
</Placemark>
</Folder>
</Folder>
<Folder>
<name>Splits</name>
<open>1</open>
<Placemark>
<name>Mile 01 - Average 9:30 /mile</name>
<styleUrl>#mile1IconStyle</styleUrl>
<Point>
<coordinates>-72.70065718058417,42.35034620333218</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Mile 02 - Average 7:02 /mile</name>
<styleUrl>#mile2IconStyle</styleUrl>
<Point>
<coordinates>-72.69023228509374,42.34685875377243</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Mile 03 - Average 5:31 /mile</name>
<styleUrl>#mile3IconStyle</styleUrl>
<Point>
<coordinates>-72.67438154801597,42.33901711755097</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Mile 04 - Average 5:01 /mile</name>
<styleUrl>#mile4IconStyle</styleUrl>
<Point>
<coordinates>-72.65690610354574,42.33421477514884</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Mile 05 - Average 4:50 /mile</name>
<styleUrl>#mile5IconStyle</styleUrl>
<Point>
<coordinates>-72.63827759351520,42.32971094144124</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Mile 06 - Average 5:14 /mile</name>
<styleUrl>#mile6IconStyle</styleUrl>
<Point>
<coordinates>-72.62312332785325,42.33428328247771</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Mile 07 - Average 4:52 /mile</name>
<styleUrl>#mile7IconStyle</styleUrl>
<Point>
<coordinates>-72.60548605458132,42.33999070825788</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Mile 08 - Average 12:19 /mile</name>
<styleUrl>#mile8IconStyle</styleUrl>
<Point>
<coordinates>-72.60283801139165,42.34127784195404</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Mile 09 - Average 4:48 /mile</name>
<styleUrl>#mile9IconStyle</styleUrl>
<Point>
<coordinates>-72.62073779424851,42.33537282683031</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Mile 10 - Average 6:10 /mile</name>
<styleUrl>#mile10IconStyle</styleUrl>
<Point>
<coordinates>-72.63579768062351,42.32850918946667</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Mile 11 - Average 5:15 /mile</name>
<styleUrl>#mile11IconStyle</styleUrl>
<Point>
<coordinates>-72.65361589561719,42.33441018120028</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Mile 12 - Average 4:55 /mile</name>
<styleUrl>#mile12IconStyle</styleUrl>
<Point>
<coordinates>-72.67259450544859,42.33756117915090</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Mile 13 - Average 5:20 /mile</name>
<styleUrl>#mile13IconStyle</styleUrl>
<Point>
<coordinates>-72.68639174648294,42.34687402676975</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Mile 14 - Average 5:08 /mile</name>
<styleUrl>#mile14IconStyle</styleUrl>
<Point>
<coordinates>-72.70087884630394,42.35314078781894</coordinates>
</Point>
</Placemark>
<Placemark>
<name>Mile 15 - Average 4:51 /mile</name>
<styleUrl>#mile15IconStyle</styleUrl>
<Point>
<coordinates>-72.69320545710393,42.34310336988481</coordinates>
</Point>
</Placemark>
</Folder>
</Document>
</kml>
Questions
- Question 1
- Write the code necessary to extract all the coordinates from the KML file and store them in two arrays, $x and $y.
- Question 2
- use functions