forked from rdmpage/geojson-phylogeny
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice.php
73 lines (58 loc) · 1.26 KB
/
service.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
// Read a NEXUS file and generate GeoJSON
require_once (dirname(__FILE__) . '/geojson_tree_drawer.php');
//--------------------------------------------------------------------------------------------------
function display_form()
{
echo
'<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" /><style type="text/css" title="text/css">
body {
font-family: sans-serif;
margin:20px;
}
</style>
<title>NEXUS to GeoJSON</title>
</head>
<body>
<h1>NEXUS to JSON</h1>
<p>Paste in NEXUS tree file containing geographical information</p>
<form method="post" action="service.php">
<textarea id="nexus" name="nexus" rows="30" cols="60"></textarea><br />
<input type="submit" value="Go"></input>
</form>
</body>
</html>';
}
//--------------------------------------------------------------------------------------------------
function convert($nexus)
{
if (!preg_match('/^#nexus/i', $nexus))
{
// error
$json = '{"status":"error"}';
}
else
{
$json = create_geojson_from_nexus($nexus);
}
echo $json;
}
//--------------------------------------------------------------------------------------------------
function main()
{
$nexus = '';
if (isset($_POST['nexus']))
{
$nexus = $_POST['nexus'];
convert($nexus);
}
else
{
display_form();
}
}
main();
?>