You are on page 1of 5

Project 8: Elephant-Package Delivery Service

COP3330 - Spring 2018

1 Problem Description
You work for Elephant-Package, a delivery service. Unlike normal delivery services, you only have one package you must
deliver (and its HUGE). Your job is as follows:

1. Receive a customer’s request to deliver a HUGE package to a location.


2. Drive to the customer’s location and pick up the package.
3. Drive to the location specified and drop off the package.

4. Drive back to the company’s HQ.


5. Show your boss the routes you took during the delivery process. *

* Your boss demands to see which routes you take during any delivery excursion. So you always create an images for him
which highlight the routes you took.
In order to get this automated, you wrote a driver program using some API code your co-worker wrote. Unfortunately,
today, the hard-drive containing all the API code (and your program) died and there are no back-ups. Your co-worker is also
sick and your boss is getting impatient not seeing the routes you took. Your immediate goal at the moment is to rewrite the
API your co-worker wrote, to the best of your knowledge. You remember the following:

• The city layout is stored in an OSM file.


• There was a class that was able to perform functionalities on OSM data.
• Some functionalities the program offered which are relevant to the task at hand:
– Plot a route from a location to another (highlighted on the image).
– Save the image of the map (with the route highlighted) to a file.

2 OSM File Structure


An OSM file is composed of a list of elements. An element can be a node, way, or relation. An element has an id
and a list of tags that describes it. A node is an element with a latitude and a longitude. A way is an element with an
ordered list of node ids. A relation is an element with an ordered list of one or more nodes, ways, and/or relations.

2.1 Clarifications
To be clear, a node is just a point on a map. A point could represent a stop sign, house, or even a point along a path (an
abstract concept; not physical). A way is just an ordered list of node ids. Ways determine all graph edges. More precisely,
two nodes are connected by an edge if they appear on adjacent lines within the text of a way, within an osm file. This project
is concerned with only those ways which are labeled as highways. .

2.2 Node
You’ll create a Node class which inherits from class Point2D. Point2D class (as usual) handles a point in 2D Euclidian
space. class Node is a specialization such that it handles both latitude and longitude and also contains the corresponding
node-id in the OSM file. The following is an example OSM node element where the id of the node is “675564556”:
<node id="675564556" visible="true" version="1" changeset="4244425" timestamp="2010-03-27T08:36:46Z"
user="NE2" uid="207745" lat="30.4790515" lon="-84.2339978"/>

1
2.3 Highways
Every highway in the OSM file is an ordered list of nodes within way tags. OSM identifies any highway with a tag containing
the key “highway”. A highway is any road, route, way, or thoroughfare on land which connects one location to another and
has been paved or otherwise improved to allow travel by some conveyance, including motorized vehicles, cyclists, pedestrians,
horse riders, and others. For more information on highways, visit the OpenStreetMap wiki.1 The following is an example of
a highway:
<way id="11059926" visible="true" version="2" changeset="14392844"
timestamp="2012-12-24T17:02:03Z" user="bot-mode" uid="451693">
<nd ref="98549913"/>
<nd ref="98638407"/>
<nd ref="98638410"/>
<nd ref="98638411"/>
<nd ref="98638413"/>
<nd ref="98638415"/>
<nd ref="98638416"/>
<nd ref="98638418"/>
<nd ref="98638419"/>
<nd ref="98638421"/>
<nd ref="98638423"/>
<nd ref="98638425"/>
<nd ref="98638428"/>
<tag k="highway" v="residential"/>
<tag k="name" v="Pine Ridge Road"/>
<tag k="tiger:cfcc" v="A41"/>
<tag k="tiger:county" v="Leon, FL"/>
<tag k="tiger:name_base" v="Pine Ridge"/>
<tag k="tiger:name_type" v="Rd"/>
<tag k="tiger:zip_left" v="32308"/>
</way>
In the above, <tag k="highway" v="residential"/> has k="highway" which determines that the way is a highway. Twelves
edges are also given, going from one node to the next, within the text above.

2.4 Critical Assumption


• The source and the destination nodes will always lie on one of the highways. So, you can parse only nodes and ways,
specifically, highways.

3 Storing the Highway Network


After parsing the osm file and extracting the highway nodes, you’ll store the nodes in a graph data structure. You can
use an adjacency matrix for this task. There will be an edge between two nodes if they are adjacent to each other in the
highway. For example, if a highway segment consists of nodes a, b, c, d in the same order, then, there will be edges between
(a, b), (b, c), (c, d). Since there is no concept of direction, edge (a, b) is the same as edge (b, a).

4 Finding the Route


Given two nodes, you’ll have to find the path between them using the adjacency matrix for which you can use Breadth First
Search. The path need not be the shortest. Any path is fine. It is possible that there may be no path at all between the
two nodes. In this assignment, however, your program will be tested with input for which the headquarters, pick-up, and
drop-off locations are all connected though highways, perhaps multiple.

5 Generating the Image Representing the Highway Network


The generated image will use the PGM format. You don’t have to write a new Matrix class, one has already been supplied
for you, and can be accessed from proj6/src if you pull the latest changeset from the course repository.
1 http://wiki.openstreetmap.org/wiki/Key:highway

2
An OSM node has a latitude and a longitude along with an id. They are provided so that when you draw a node in an
image, you know the position it should be drawn at. In this case, since you are drawing the highway network, you need to
draw the edges connecting nodes in a way.
The bounding latitudes and longitudes for the OSM data are provided in the bounds xml datum, usually located at the
top of the file. Since both latitude and longitude have a fractional part of 7 decimal places, it’s not feasible to draw one pixel
per unique coordinate possible. However, since we have the OSM data for only a single city, the difference in the decimal
values is small. Find the maximal number of decimal points that differ between the bounding latitudes and between the
bounding longitudes and then determine a scaling factor such that the image is no larger than 5,000x5,000 pixels. Adjust
the image to account for aspect ratio.
The gray scale image will have the following coloring scheme:
• Background = 255

• All Highways = 150


• Route from start node to destination node = 50.

6 Input Requirements and Output


Sample Run:

./maps
FSUStadium.osm
98565457
667207015
1404392390

The first line is the osm file that will be read. Your program should read it from the osm directory. The next three lines gives
the node ids for the headquarters, pickup, and drop-off nodes. Your program should not cout any information. It should
write a pgm map with all the routes taken.
You can try yet another sample program run:

./maps
WescottFountain.osm
1407975682
1407984386
2689709258

7 ABET Assessment
This course is one of the Computer Science department courses designated for assessing certain student outcomes, required
by SMALC/SACS and ABET for accreditation purposes. This assessment will be done with 2 different programming as-
signments in the course, designated as such because they will incorporate multiple aspects of programming skills learned to
date. They will be scored in several areas on a scale of values including ”Ineffective”, ”Effective”, and ”Highly Effective”.
Each student must achieve an overall score of ”Effective” or higher (Earning 70% of available assignment points will count
as ”Effective”) on at least ONE of the two designated assignments.

The specific outcomes being measured in this assignment are:


• Given a class Point2D, the student will be able to derive a new inherited class Node from it.

• Given the existing implementatiom of class OSM, student will be able to modify it to suit the problem needs.
A score of 70 will satisfy the ABET requirement for this assignment.

A Point2D class header file is provided. Please make a separate Point2D cpp file. Also make a separate Node class which
must inherit from the Point2D class. Also make separate node.cpp and node.hpp files.

3
8 Grading Rubric
This project is worth two homework assignments for a total of 200 points. The grading for this project is split into three
parts. All three parts are related to the Osm class which must be modified and should ideally be completed in the following
order:
1. Parsing an OSM file and storing the relevant data.

2. Using a data structure to represent the highway network.


3. Creating the basic PGM image which contains the highway network, highway nodes, and the larger headquarters,
pick-up, and drop-off nodes.
4. Creating a PGM image for each route.

8.1 Parsing an OSM File (60 pts.)


• Parsed the OSM file correctly and stored the relevant nodes and ways which are highways.

– (20 pts.) Wrote classes to represent the OSM elements needed by the revised Osm class.
– (5 pts.) Parsed the bounding latitudes and longitudes.
– (15 pts.) nodes parsed and stored appropriately.
– (20 pts.) ways parsed and stored appropriately.

8.2 Representing the Highway Network (70 pts.)


• (40 pts.) Implemented appropriate data structures. For instance, the structures must store all map data appropriately
and be used appropriately.

• (20 pts.) Implemented a pathfinding algorithm that uses the data structures (e.g. adjacency list, breadth-first search,
and all that is required for the algorithm).
• (10 pts.) Derived an inherited Node class which is used in the highway network.

8.3 Creating the Image (70 pts.)


• (10 pts.) Determined the dimensions of the image. A pgm image of correct size is output.
• (20 pts.) Highways and nodes are all drawn correctly, according to specifications

• (30 pts.) All routes highlighted correctly.


• (10 pts.) Correct colors.

8.4 Penalties
• Fails to compile after fixing two compiler errors. (-200 pts.)

• No Makefile. (-200 pts.)

• regex library used (-60 pts.)

• Putting more than the necessary source files in the repository. Empty directories may be needed. (-200 pts.)

– Always do a make clean before you push your changes.


– Don’t push any .osm, .o, or executable files.
– Only push the doxyfile, not what it produces.

9 Due Date and Time


Sunday April 22, 11:59 pm

4
10 Hints
This project tests the following:
• Critical Thinking
– What members should the new modified Osm class have?
– If the highway network is just a set of nodes and edges (i.e. a graph), which data structure should you choose to
implement (see the course slides Structuring Data)?
– How do you fill up the data structure given the data you parse from an OSM file (this is reliant on how you
implement your member data)?
• Time Management

– This project is long and will require lots of thinking. If you start on the last day, or even the last week, you might
fail. Start early. Commit often.
• Code Reuse
– The Osm class from Project 5 will be reused and slightly modified. Please store all related files with the name
“osm rev” (e.g. osm rev.cpp, osm rev.hpp, osm rev.o).
– The Matrix class from Project 6 will be reused and slightly modified. It has been provided to you. Please store
all related files with the name “matrix rev” (e.g. matrix rev.cpp, matrix rev.hpp, matrix rev.o).
• Inheritance

11 Mandatory Functions of the Project


• Osm::Osm(std::string osmFileName);
• void Matrix::Save(std::string imgFilename);

12 Helpful Links
• Graphs as Adjacency list, http://www.algolist.net/Data_structures/Graph/Internal_representation
• Breadth First Search, https://en.wikipedia.org/wiki/Breadth-first_search

You might also like