gt: 			if (previus instanceof SpatialCoordItem) {
context: package org.chaseme.drone.variables.mission;
  
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.List;
  
  import org.chaseme.drone.Drone;
  import org.chaseme.drone.DroneInterfaces.DroneEventsType;
  import org.chaseme.drone.DroneInterfaces.OnDroneListener;
  import org.chaseme.drone.DroneVariable;
  import org.chaseme.drone.variables.mission.survey.Survey;
  import org.chaseme.drone.variables.mission.waypoints.SpatialCoordItem;
  import org.chaseme.drone.variables.mission.waypoints.Waypoint;
  import org.chaseme.fragments.helpers.MapPath.PathSource;
  import org.chaseme.fragments.markers.MarkerManager.MarkerSource;
  import org.chaseme.helpers.geoTools.GeoTools;
  import org.chaseme.helpers.units.Altitude;
  import org.chaseme.helpers.units.Length;
  
  import android.widget.Toast;
  
  import com.MAVLink.Messages.ardupilotmega.msg_mission_ack;
  import com.MAVLink.Messages.ardupilotmega.msg_mission_item;
  import com.MAVLink.Messages.enums.MAV_CMD;
  import com.google.android.gms.maps.model.LatLng;
  
  public class Mission extends DroneVariable implements PathSource{
  
  	private List<MissionItem> itens = new ArrayList<MissionItem>();
  	private List<MissionItem> selection = new ArrayList<MissionItem>();
  	private Altitude defaultAlt = new Altitude(20.0);
  
  	public Mission(Drone myDrone) {
  		super(myDrone);
  	}
  
  	public Altitude getDefaultAlt() {
  		return defaultAlt;
  	}
  
  	public void setDefaultAlt(Altitude newAltitude) {
  		defaultAlt = newAltitude;		
  	}
  
  	public void removeWaypoint(MissionItem item) {
  		itens.remove(item);
  		selection.remove(item);
  		notifiyMissionUpdate();
  	}
  
  	public void removeWaypoints(List<MissionItem> toRemove) {
  		itens.removeAll(toRemove);
  		selection.removeAll(toRemove);
  		notifiyMissionUpdate();		
  	}
  
  	public void addWaypoints(List<LatLng> points) {
  		Altitude alt = getLastAltitude();
  		for (LatLng point : points) {
  			itens.add(new Waypoint(this, point,alt));
  		}		
  		notifiyMissionUpdate();
  	}
  
  	public void addWaypoint(LatLng point) {
  		itens.add(new Waypoint(this,point,getLastAltitude()));
  		notifiyMissionUpdate();
  	}
  
  	public void notifiyMissionUpdate() {
  		myDrone.events.notifyDroneEvent(DroneEventsType.MISSION_UPDATE);
  	}
  
  	private Altitude getLastAltitude() {
  		Altitude alt;
  		try{
  			SpatialCoordItem lastItem = (SpatialCoordItem) itens.get(itens.size()-1);
  			alt = lastItem.getAltitude();
  		}catch (Exception e){
  			alt = defaultAlt;			
  		}
  		return alt;
  	}
  	
  	public void replace(MissionItem oldItem, MissionItem newItem) {
  		int index = itens.indexOf(oldItem);
  		if (selectionContains(oldItem)) {
  			removeItemFromSelection(oldItem);
  			addToSelection(newItem);
  		}
  		itens.remove(index);
  		itens.add(index, newItem);
  		notifiyMissionUpdate();		
  	}
  
  	public void reverse() {
  		Collections.reverse(itens);
  		notifiyMissionUpdate();	
  	}
  
  	/**
  	 * Moves the selected objects up or down into the mission listing
  	 * 
  	 * Think of it as pushing the selected objects, while you can only move a
  	 * single unselected object per turn.
  	 * 
  	 * @param moveUp
  	 *            true to move up, but can be false to move down
  	 */
  	public void moveSelection(boolean moveUp) {
  		if (selection.size() > 0 | selection.size() < itens.size()) {
  			Collections.sort(selection);
  			if (moveUp) {
  				Collections.rotate(getSublistToRotateUp(), 1);				
  			}else{
  				Collections.rotate(getSublistToRotateDown(), -1);
  			}
  			notifiyMissionUpdate();
  		}
  	}
  
  	private List<MissionItem> getSublistToRotateUp() {
  		int from = itens.indexOf(selection.get(0));
  		int to = from;
  		do{
  			if (itens.size() < to + 2)
  				return itens.subList(0, 0);
  		}while (selection.contains(itens.get(++to)));
  		return itens.subList(from, to + 1); // includes one unselected item
  	}
  
  	private List<MissionItem> getSublistToRotateDown() {
  		int from = itens.indexOf(selection.get(selection.size() - 1));
  		int to = from;
  		do {
  			if (to < 1) {
  				return itens.subList(0, 0);
  			}
  		} while (selection.contains(itens.get(--to)));
  		return itens.subList(to, from + 1); // includes one unselected item
  	}
  
  	public void addSurveyPolygon(List<LatLng> points) {
  		Survey survey = new Survey(this, points, myDrone.context);
  		itens.add(survey);
  		notifiyMissionUpdate();		
  	}
  
  	public void onWriteWaypoints(msg_mission_ack msg) {
  		Toast.makeText(myDrone.context, "Waypoints sent", Toast.LENGTH_SHORT)
  				.show();
  		myDrone.tts.speak("Waypoints saved to Drone");
  	}
  
  	@Override
  	public List<LatLng> getPathPoints() {
  		List<LatLng> newPath = new ArrayList<LatLng>();
  		for (MissionItem item : itens) {
  			try {
  				newPath.addAll(item.getPath());
  			} catch (Exception e) {
  				// Exception when no path for the item
  			}
  		}
  		return newPath;
  	}
  
  	public List<MissionItem> getItems() {
  		return itens;
  	}
  
  	public List<MarkerSource> getMarkers() {
  		List<MarkerSource> markers = new ArrayList<MarkerSource>();
  		for (MissionItem item : itens) {
  			try {
  				markers.addAll(item.getMarkers());
  			} catch (Exception e) {
  				// Exception when no markers for the item
  			}
  		}
  		return markers;
  	}
  
  	public Integer getNumber(MissionItem waypoint) {
  		return itens.indexOf(waypoint)+1; // plus one to account for the fact that this is an index
  	}
  
  	public Length getAltitudeDiffFromPreviusItem(
  			SpatialCoordItem waypoint) throws Exception {
  		int i = itens.indexOf(waypoint);
  		if (i > 0) {
  			MissionItem previus = itens.get(i - 1);
  			if (previus instanceof SpatialCoordItem) {
  				return waypoint.getAltitude().subtract(
  						((SpatialCoordItem) previus).getAltitude());
  			}
  		}
  		throw new Exception("Last waypoint doesn't have an altitude");
  	}
  
  	public Length getDistanceFromLastWaypoint(SpatialCoordItem waypoint) throws Exception {
  		int i = itens.indexOf(waypoint);
  		if (i > 0) {
  			MissionItem previus = itens.get(i - 1);
  