source: subversion/sites/other/freemap/common/inc.php @ 8877

Last change on this file since 8877 was 5736, checked in by nick, 12 years ago

various changes to Freemap/Osmajax?

File size: 4.2 KB
Line 
1<?php
2session_start();
3
4function write_sidebar()
5{
6?>
7        <div id='sidebar'>
8        <div class='titlebox'>
9        <img src='/images/freemap_small.png' alt='freemap_small' /><br/>
10        </div>
11        <div id='login'>
12        <?php
13        if(!isset($_SESSION['gatekeeper']))
14        {
15                ?>
16                <form method="post" action="/freemap/common/login.php">
17                <label for="username">Username</label> <br/>
18                <input name="username" id="username" /> <br/>
19                <label for="password">Password</label> <br/>
20                <input name="password" id="password" type="password" /> <br/>
21                <input type='submit' value='go'/>
22                </form>
23                <p><a href='/freemap/common/signup.php'>Sign up</a></p>
24                <?php
25        }
26        else
27        {
28                echo "<p>Logged in as <em>$_SESSION[gatekeeper]</em><br/>".
29                 "<a href='/freemap/home.php'>".
30                 "My home page</a>".
31                 "<a href='/freemap/gpxtodb.php'>".
32                 "Upload GPX</a>".
33                 " <a href='/freemap/common/logout.php?referrer=$_SERVER[PHP_SELF]'>".
34                 "Log out</a></p>\n";
35        }
36
37        ?>
38        </div>
39
40        <div>
41        <input type='button' value='Done with walk route!' id='wrdonebtn'/>
42        </div>
43
44
45        <div id='editpanel'></div>
46        <div id='infopanel'></div>
47        <div id="message"> </div>
48
49        </div>
50        <?php
51}
52
53function write_searchbar()
54{
55?>
56<div id='srch'>
57<label for='search'>Search:</label>
58<input id="search" /> 
59<input type='hidden' id='country' value='uk' />
60<input type='button' id='searchButton' value='Go!'/>
61<?php
62}
63
64function write_milometer()
65{
66?>
67<span id='milometer'>
68<span id='distUnits'>000</span>.<span id='distTenths'>0</span>
69</span>
70<select id='units'>
71<option>miles</option>
72<option>km</option>
73</select>
74<input type='button' value='Reset' id='resetDist' />
75</div>
76<?php
77}
78
79function write_editcontrols()
80{
81echo "<div>";
82/*
83$controls = array("navigate"=>"navigate","draw"=> "add feature",
84                                        "edit"=>"edit feature");
85echo "<span class='menubar'>";
86$first=true;
87foreach ($controls as $control=>$displayed)
88{
89        if($first)
90                $first=false;
91        else
92                echo " | ";
93        echo "<span id=\"mode_$control\" onclick=\"setEditMode('$control')\">".
94                 "$displayed</span>";
95}
96echo "</span>";
97*/
98echo "<span class='menubar'>";
99//echo "<span onclick='changeFeature()'>CHANGE</span>";
100echo "</span>  <span class='menubar'>";
101echo "<a href='edit.php?basemap=npe' id='base_npe'>NPE</a> | ";
102echo "<a href='edit.php?basemap=freemap' id='base_freemap'>Freemap</a> | ";
103echo "<a href='edit.php?basemap=osm' id='base_osm'>tiles@home</a> | ";
104echo "<a href='edit.php?basemap=landsat' id='base_landsat'>Landsat</a> ";
105//echo "<input type='button' onclick='testlayer()' value='testlayer'/>";
106echo "</div>";
107}
108
109
110function write_osmloginform($post_script="")
111{
112        ?>
113        <h1>OpenStreetMap POI Editor</h1>
114        <h2>Please log in to OSM</h2>
115        <p>To use this feature, you need to provide your OpenStreetMap
116        username and password. If you don't have one, please visit
117        <a href='http://www.openstreetmap.org'>OpenStreetMap</a>.</p>
118        <p><strong>Important:</strong>
119        Please note that Freemap will store your OSM username and password on
120        the server until you choose to log out of OSM, and will send your OSM
121        login details to the OSM server every time an edit is made. <em>Please
122        only continue if you're happy with this.</em></p>
123        <p>
124        <form method="post" action="<?php echo $post_script; ?>">
125        <label for="osmusername">OSM Username:</label><br/>
126        <input name="osmusername" id="osmusername"/><br/>
127        <label for="osmusername">OSM Password:</label><br/>
128        <input name="osmpassword" id="osmpassword" type="password"/><br/>
129        <input type="submit" value="Go!"/>
130        </p>
131        </form>
132        <?php
133}
134
135function do_coords($proj,$inp)
136{
137        $_SESSION['lon'] = isset($inp['lon']) ? $inp['lon']:
138                (isset($_SESSION['lon'])  ? $_SESSION['lon'] : -0.72 );
139        $_SESSION['lat'] = isset($inp['lat']) ? $inp['lat']:
140                (isset($_SESSION['lat'])  ? $_SESSION['lat'] : 51.05 );
141
142        switch($proj)
143        {
144                case "Mercator":
145                        $en = ll_to_merc ($_SESSION['lat'],$_SESSION['lon']);
146                        break;
147       
148                case "OSGB":
149                        $en = wgs84_ll_to_gr 
150                        (array("lat"=>$_SESSION['lat'],"long"=>$_SESSION['lon']));
151                        break;
152
153                case "GOOG":
154                        $en=array();
155                $a = log(tan((90+$_SESSION['lat'])*M_PI / 360))/(M_PI / 180);
156                        $en['n'] = $a * 20037508.34 / 180;
157                        $en['e']=$_SESSION['lon'];
158                        $en['e'] = $en['e'] * 20037508.34 / 180;
159                        break;
160
161                default:
162                        $en = array ("e"=>$_SESSION['lon'], "n"=>$_SESSION['lat']);
163        }
164        return $en;
165}
166?>
Note: See TracBrowser for help on using the repository browser.