add a course id search and some docs

pull/1678/head
Jason Dekarske 2022-04-08 17:30:34 -07:00
parent bbcf98edad
commit 66fbc48a10
3 changed files with 63 additions and 22 deletions

View File

@ -1,8 +1,8 @@
# App Name # App Name
Describe the app... This app leverages open source map data to give you a birds eye view of your golf game! See a preview of any hole as well as your realtime distance to the green and position on the hole.
Add screen shots (if possible) to the app folder and link then into this file with ![](<name>.png) ![hole3](screenshot.png)
## Usage ## Usage
@ -10,8 +10,20 @@ Select your course of interest upon loading this app.
## Contributions ## Contributions
The performance of this app depends on the accuracy and consistency of user-submitted maps. Please contribute to Open Street Map using these guidelines and provide input in ways to support this application. The performance of this app depends on the accuracy and consistency of user-submitted maps.
<ul>
<li>See official mapping guidelines <a
href="https://wiki.openstreetmap.org/wiki/Tag:leisure%3Dgolf_course">here</a>.</li>
<li>All holes and features must be within the target course's area.</li>
<li>Supported features are greens, fairways, tees, bunkers, water hazards and holes.</li>
<li>All features for a given hole should have the "ref" tag with the hole number as value. Shared features should
list ref values separated by ';'. <a href="https://www.openstreetmap.org/way/36896320">example</a>.</li>
<li>There must be 18 holes and they must have the following tags: handicap, par, ref, dist</li>
<li>For any mapping assistance or issues, please file in the <a
href="https://github.com/espruino/BangleApps/issues/new?assignees=&labels=bug&template=bangle-bug-report-custom-form.yaml&title=[golfview]+Short+description+of+bug">official
repo</a></li>
</ul>
<a href="https://www.openstreetmap.org/way/25447898">Example Course</a>
## Controls ## Controls
Swipe to change holes and tap to see a green closeup. Swipe to change holes and tap to see a green closeup.

View File

@ -8,10 +8,28 @@
</head> </head>
<body> <body>
<p id="status">No course</p>
<div> <div>
<button id="upload" class="btn btn-primary" disabled="true">Upload to Device</button> <input type="text" placeholder="Course ID" id="course_id">
<button id="download" class="btn btn-primary" disabled="true">Download Course</button> <button type="button" onclick="courseSearch();">Search</button>
<p id="status"></p>
<div>
<button id="upload" class="btn btn-primary" disabled="true">Upload to Device</button>
<button id="download" class="btn btn-primary" disabled="true">Download Course</button>
</div>
<p>A course needs a few things to be parsed correctly by this tool.</p>
<ul>
<li>See official mapping guidelines <a
href="https://wiki.openstreetmap.org/wiki/Tag:leisure%3Dgolf_course">here</a>.</li>
<li>All holes and features must be within the target course's area.</li>
<li>Supported features are greens, fairways, tees, bunkers, water hazards and holes.</li>
<li>All features for a given hole should have the "ref" tag with the hole number as value. Shared features should
list ref values separated by ';'. <a href="https://www.openstreetmap.org/way/36896320">example</a>.</li>
<li>There must be 18 holes and they must have the following tags: handicap, par, ref, dist</li>
<li>For any mapping assistance or issues, please file in the <a
href="https://github.com/espruino/BangleApps/issues/new?assignees=&labels=bug&template=bangle-bug-report-custom-form.yaml&title=[golfview]+Short+description+of+bug">official
repo</a></li>
</ul>
<a href="https://www.openstreetmap.org/way/25447898">Example Course</a>
</div> </div>
<script src="../../core/lib/customize.js"></script> <script src="../../core/lib/customize.js"></script>
@ -19,10 +37,15 @@
<script> <script>
const url = "https://overpass-api.de/api/interpreter"; const url = "https://overpass-api.de/api/interpreter";
//let query = `[bbox:37.4829,-122.8694,39.7110,-120.6215][out:json][timeout:5];way["name"="El Macero Country Club"];map_to_area ->.golfcourse;way["golf"="hole"](area.golfcourse)->.holes;(relation["golf"="fairway"](area.golfcourse);way["golf"~"^(green|tee|water_hazard|bunker|fairway)"](area.golfcourse);)->.features;.holes out geom;.features out geom;`; let query = `[out:json][timeout:5];way(25447898);map_to_area ->.golfcourse;way["golf"="hole"](area.golfcourse)->.holes;(relation["golf"="fairway"](area.golfcourse);way["golf"~"^(green|tee|water_hazard|bunker|fairway)"](area.golfcourse);)->.features;.holes out geom;.features out geom;`;
let query = `[bbox:37.4829,-122.8694,39.7110,-120.6215][out:json][timeout:5];way["name"="Davis Golf Course"];map_to_area ->.golfcourse;way["golf"="hole"](area.golfcourse)->.holes;(relation["golf"="fairway"](area.golfcourse);way["golf"~"^(green|tee|water_hazard|bunker|fairway)"](area.golfcourse);)->.features;.holes out geom;.features out geom;`;
let course_input = null; let course_input = null;
function courseSearch() {
let inputVal = document.getElementById("course_id").value;
query = `[out:json][timeout:5];way(${inputVal});map_to_area ->.golfcourse;way["golf"="hole"](area.golfcourse)->.holes;(relation["golf"="fairway"](area.golfcourse);way["golf"~"^(green|tee|water_hazard|bunker|fairway)"](area.golfcourse);)->.features;.holes out geom;.features out geom;`;
doQuery();
}
function processFeatures(course_verbose) { function processFeatures(course_verbose) {
let course_processed = { let course_processed = {
holes: {} holes: {}
@ -104,19 +127,25 @@
}); });
// download info from the course // download info from the course
$.post(url, query, function (result) { function doQuery() {
course_input = result; $.post(url, query, function (result) {
console.log(course_input); if (result.elements.length === 0) {
out = processFeatures(course_input.elements); $('#status').text("Course not found!");
console.log(out); return;
courses.push({ }
name: "golfcourse-" + course_name + ".json", course_input = result;
content: JSON.stringify(out), console.log(course_input);
}); out = processFeatures(course_input.elements);
$('#status').text("Course retrieved!"); console.log(out);
$('#upload').attr("disabled", false); courses.push({
$('#download').attr("disabled", false); name: "golfcourse-" + course_name + ".json",
}) content: JSON.stringify(out),
});
$('#status').text("Course retrieved!");
$('#upload').attr("disabled", false);
$('#download').attr("disabled", false);
})
}
</script> </script>
</body> </body>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB