package de.mrunde.bachelorthesis.instructions;

import com.mapquest.android.maps.GeoPoint;

import de.mrunde.bachelorthesis.basics.Landmark;

/**
 * This is a "global landmark"-based instruction.
 * 
 * @author Marius Runde
 */
public class GlobalInstruction extends Instruction {

	/**
	 * The global landmark along the route
	 */
	private Landmark global;

	/**
	 * Constructor of the GlobalInstruction class
	 * 
	 * @param instructionPoint
	 *            The point where the instruction should be spoken
	 * @param global
	 *            The global landmark along the route
	 */
	public GlobalInstruction(GeoPoint instructionPoint, Landmark global) {
		super(instructionPoint, 0);
		this.global = global;
	}

	/**
	 * @return The instruction as a verbal text
	 */
	public String toString() {
		String instruction = "You will pass ";
		String category = this.global.getFormattedCategory();
		if (category.startsWith("a") || category.startsWith("e")
				|| category.startsWith("i") || category.startsWith("o")
				|| category.startsWith("u")) {
			instruction += "an " + category + " soon";
		} else {
			instruction += "a " + category + " soon";
		}
		return instruction;
	}

	/**
	 * @return The extended instruction as a verbal text which uses the title of
	 *         the landmark instead of its category
	 */
	public String toExtendedString() {
		String instruction = "You will pass ";
		String title = this.global.getTitle();
		if (title.startsWith("a") || title.startsWith("e")
				|| title.startsWith("i") || title.startsWith("o")
				|| title.startsWith("u")) {
			instruction += "an " + title + " soon";
		} else {
			instruction += "a " + title + " soon";
		}
		return instruction;
	}

	/**
	 * @return The global landmark along the route
	 */
	public Landmark getGlobal() {
		return this.global;
	}
}

@@ -138,16 +138,74 @@
 ndmark;%0D
+%0Aimport de.mrunde.bachelorthesis.basics.LandmarkCategory;%0D
 %0A%0D%0A/**%0D%0A
@@ -929,26 +929,48 @@
 %0D%0A%09%09
-String category = 
+if (LandmarkCategory.SIGHTSEEING.equals(
 this
@@ -984,17 +984,8 @@
 .get
-Formatted
 Cate
@@ -994,166 +994,80 @@
 ry()
-;%0D%0A%09%09if (category.startsWith(%22a%22) %7C%7C category.startsWith(%22e%22)%0D%0A%09%09%09%09%7C%7C category.startsWith(%22i%22) %7C%7C category.startsWith(%22o%22)%0D%0A%09%09%09%09%7C%7C category.startsWith(%22u%22)) %7B
+)) %7B%0D%0A%09%09%09// Use landmark title for landmarks of the category SIGHTSEEING
 %0D%0A%09%09
@@ -1087,23 +1087,38 @@
 += %22
-an
+the
  %22 + 
-category
+this.global.getTitle()
  + %22
@@ -1130,32 +1130,85 @@
 %22;%0D%0A%09%09%7D else %7B%0D%0A
+%09%09%09// Use landmark category for all other landmarks%0D%0A
 %09%09%09instruction +
@@ -1214,23 +1214,57 @@
 += %22
-a
+the
  %22 + 
-category 
+this.global.getFormattedCategory()%0D%0A%09%09%09%09%09
 + %22 
@@ -1525,28 +1525,15 @@
 ass 
-%22;%0D%0A%09%09String title =
+the %22 +
  thi
@@ -1555,255 +1555,24 @@
 le()
-;
 %0D%0A%09%09
-if (title.startsWith(%22a%22) %7C%7C title.startsWith(%22e%22)%0D%0A%09%09%09%09%7C%7C title.startsWith(%22i%22) %7C%7C title.startsWith(%22o%22)%0D%0A%09%09%09%09%7C%7C title.startsWith(%22u%22)) %7B%0D%0A%09%09%09instruction += %22an %22 + title + %22 soon%22;%0D%0A%09%09%7D else %7B%0D%0A%09%09%09instruction += %22a %22 + title + %22 soon%22;%0D%0A%09%09%7D
+%09%09+ %22 soon%22;
 %0D%0A%09%09

Improve usage of sightseeing landmarks in GlobalInstruction