Skip to content
Snippets Groups Projects
Commit 2cabb01d authored by Peter J. Keleher's avatar Peter J. Keleher
Browse files

auto

parent f238c0d1
No related branches found
No related tags found
No related merge requests found
assign4 0 → 100644
This diff is collapsed.
# Assignment 4: Documents And MapKit
**Due: Apr 19, 2020, 11:59:59 pm, v1**
NOTE THAT THIS IS AN EVOLVING DOCUMENT and will surely change to
incorporate more information and hints as the two weeks go by. UPDATE
FREQUENTLY.
## Goals
Learn to use:
- UIDocument abstractions
- Document Browser
- MapKit
You will build a biking or running GPS tracker app that saves and displays tracks
through the document browser. See the following for a short demo of a
running version of this app:
![](https://sedna.cs.umd.edu/436clips/assign4.mov)
## Tasks
The following is a suggested series of steps for you to take, together
with approximate points that each step will be worth. You can ignore
all this and just emulate the first video above. Doing that gets you
full points. However, the following set of steps is a good approach to
building this app methodically.
## Step 1: Circles (20 pts)
-Emulate the functionality of the [Circles](https://sedna.cs.umd.edu/436clips/circles.mp4) app from 4/7.
In your version:
- the browser should work,
- "+" brings up another view controller that allow you to visibly
create something (circles are easy), saved back to a file that can
- later be-reopened
You do NOT have to create the Circles app, but slavishly
following what I did in the demo and turning in Circles will get you
20 pts (and count as a Good Faith Attempt).
## Step 2: Showing a Map (10 pts)
Go through the videos on 4/8 for [Core Location](https://sedna.cs.umd.edu/436clips/OUT12coreLocation.mp4) and [MapKit](https://sedna.cs.umd.edu/436clips/OUT12mapkit.mp4).
On clicking a "+" button we see the map *with* the user's current
position marked, if in view. A button allows the map to be
dismissed. No tracking or line drawing needed, an empty Circles file
could be written to the file system.
## Step 3: Tracking the Rider (20 pts)
- Set up location updating to get location updates.
- Keep the user centered in the middle of the screen in a region with
an appropriate zoom level. Do this by choosing the *last* point given in
each location update (there may be many), and creating a
`MKCoordinateRegion` with that point as the center, and a radius of
300 meters.
## Step 4: Drawing the Line (20 pts)
- At each call of your `locationManager(manager:, didUpdateLocations:)`,
you will be given an array of one or more `CLLocation`s. Draw a
polyline connecting the last previous point to all the points given in
this call.
- Overload `mapView(mapView:, rendererFor overlay: )` to give your
line appropriate attritutes: red, and lineWidth 3.
Make it work on different-sized phones, w/ orientation changes. Make
it look decent. Add a control to toggle between map and satellite views.
## Step 5: Saving the File and Viewing Saved Files (20 pts)
Write important information to the file. Define a `GPXTrack` that
contains information about the track, including but not limited to the
set of GPS points received from Core Location.
You will need to have routines to serialize to and from JSON, which is
cast as a `Data`, which is then written/read to/from the file.
## Step 5: Somethin' Else
(10 pts)
No, I'm not talking about a classic jazz album, I mean that you must
pick and implement one of the items from the list below to get the
final 10 pts.
## Hints
- My first app used the simple format specified below.
```
struct GPXPoint: Codable {
var latitude: Double
var longitude: Double
var altitude: Double
var time: Date
}
struct GPXSegment: Codable {
var coords : [GPXPoint]
}
struct GPXTrack : Codable {
var name : String
var link : String
var time : String
var segments : [GPXSegment] = []
var distance = "-"
var feetClimbed = "-"
}
```
- Your GPXDocument override both `contents()` and `load()`, and should
probably have a property that holds a reference to the current track.
## Additional Task, and Extra Credit
Pick one of the tasks below for the last 10 points of this project.
Pick up to another three for 10 pts bonus for each you accomplish (up to a max of three), or a donut each,
your choice. You'd have to come by to pick up the donut. The points
will be appliable on either the `assign5` or the final (which will be
out of 200 pts):
- *Get your app to read and write files with the .gpx extension*. Instead of
reading and writing .gpx436, read and write .gpx. Here, I'm just
asking you to get the UTI setup correct so that the document and
browser will allow you to read and write files with the `.gpx`
extension. Doesn't matter what you write.
- *Get your app to read and write real gpx files*. Your app should be
able to write read and write RideWithGPX files. Don't worry, look at
[this file](bmwRS1200.gpx) and you will see the format is dirt simple (though
there may be multiple `trkseg`s).
- *Show a pre-planned route*. Show the route (w/ a
different color) from another gpx file as you are recording a ride, so that the rider can
follow a pre-planned route. Allow the user to choose which other
ride to use by adding a button to the screen which showing a
pre-recorded ride. Must be able to turn this off as well.
- *Poor man's turn-by-turn navigation* - The best way to do turn-by-turn
navigation is to know when and where you turn onto a different
street. We don't have that information, so you can try to use
heuristics, like "turned left or right between 70 and 110 degrees
and stayed on the new heading two or three points". Display the
navigation in a line overlaying the map at the top of the
screen. Navigation cues should be of the form: "Turn right in 50
feet", just showing the next turn. Of course, this only works if you
have a pre-planned route as above.
- (5 pts) *Map orientation button* - Display a little icon (maybe check out *MKCompassButton*) that when
clicked upon changes the map orientation so that either the current
direction of travel is "up", or north is "up".
- (5 pts) *Tracking vs not tracking map* By default, our app *tracks* the
rider on the map: keeps him/her centered in the middle of the screen with a set
magnification. Cease tracking you detect that the rider has manipulated the display,
either moving, zooming, or rotating. Allow the rider to restart
tracking by hitting a button, ideally the above map orientation button.
{"segments":[{"coords":[{"latitude":37.731884540000003,"longitude":-122.41767864000001,"time":607897969.16319203,"altitude":0},{"latitude":37.731885300000002,"longitude":-122.41730588999999,"time":607897970.15297794,"altitude":0},{"latitude":37.731878879999996,"longitude":-122.41694044,"time":607897971.16292,"altitude":0},{"latitude":37.7318845,"longitude":-122.41657121999999,"time":607897972.16060698,"altitude":0},{"latitude":37.731911410000002,"longitude":-122.41621021,"time":607897973.15761805,"altitude":0},{"latitude":37.73195415,"longitude":-122.4158549,"time":607897974.17632103,"altitude":0},{"latitude":37.73201031,"longitude":-122.41551108,"time":607897975.17622006,"altitude":0},{"latitude":37.73208047,"longitude":-122.41515560000001,"time":607897976.11131203,"altitude":0},{"latitude":37.732167680000003,"longitude":-122.41480448,"time":607897977.14846396,"altitude":0},{"latitude":37.732255479999999,"longitude":-122.41446292000001,"time":607897978.14783204,"altitude":0}]}],"distance":"0.3","feetClimbed":"-","name":"example.gpx436","time":"04-06-20 16:33:06","link":""}
\ No newline at end of file
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment