Index: trunk/lib/FlairCore/src/FrameworkManager_impl.cpp
===================================================================
--- trunk/lib/FlairCore/src/FrameworkManager_impl.cpp	(revision 62)
+++ trunk/lib/FlairCore/src/FrameworkManager_impl.cpp	(revision 67)
@@ -181,9 +181,9 @@
     status = UDT::close(com_sock);
     if (status != 0)
-      printf("Error udt::close %s", UDT::getlasterror().getErrorMessage());
+      Printf("Error udt::close %s", UDT::getlasterror().getErrorMessage());
 
     status = UDT::close(file_sock);
     if (status != 0)
-      printf("Error udt::close %s", UDT::getlasterror().getErrorMessage());
+      Printf("Error udt::close %s", UDT::getlasterror().getErrorMessage());
 
     SleepMS(200); // a revoir, sinon UDT::cleanup bloque en RT
@@ -294,5 +294,5 @@
         xmlDoc *doc;
         rcv_buf[bytesRead] = 0;
-
+ //Printf("%s\n",rcv_buf);
         doc = xmlReadMemory(rcv_buf, (int)bytesRead, "include.xml",
                             "ISO-8859-1", 0);
Index: trunk/lib/FlairCore/src/Map.cpp
===================================================================
--- trunk/lib/FlairCore/src/Map.cpp	(revision 62)
+++ trunk/lib/FlairCore/src/Map.cpp	(revision 67)
@@ -21,4 +21,5 @@
 #include "GeoCoordinate.h"
 #include "FrameworkManager.h"
+#include <cmath>
 #include <string.h>
 #include <sstream>
@@ -80,8 +81,7 @@
 void Map::ExtraXmlEvent(void) {
 
-  // attention pas rt safe (creation checkpoint)
+  // attention pas rt safe (creation/destruction checkpoint)
   size_t i = 0;
   while (1) {
-    // printf("test %i\n",i);
     double latitude, longitude;
     double altitude = 0;
@@ -90,13 +90,20 @@
     long_prop << "long" << i;
     alt_prop << "alt" << i;
+
     if (GetPersistentXmlProp(lat_prop.str(), latitude) &&
         GetPersistentXmlProp(long_prop.str(), longitude)) {
       GetPersistentXmlProp(alt_prop.str(), altitude);
+
       if (i >= checkpoints.size()) {
+        //add checkpoint
         GeoCoordinate *checkpoint = new GeoCoordinate(
             this, "checkpoint", latitude, longitude, altitude);
         checkpoints.push_back(checkpoint);
-        // printf("add %i\n",i);
+      } else if(isnan(latitude) || isnan(longitude)) {
+        //delete checkpoint
+        removeCheckpoint(i);
+        break;//si delete, la station sol n'envoit que cette info
       } else {
+        //move checkpoint
         checkpoints.at(i)->SetCoordinates(latitude, longitude, altitude);
       }
@@ -107,10 +114,32 @@
     i++;
   }
-
+/*
   for (size_t i = 0; i < checkpoints.size(); i++) {
     double latitude, longitude, altitude;
     checkpoints.at(i)->GetCoordinates(&latitude, &longitude, &altitude);
-    // printf("%i %f %f\n",i,latitude,longitude);
+     printf("%i %f %f\n",i,latitude,longitude);
+  }*/
+}
+
+void Map::removeCheckpoint(size_t index) {
+  //left shift
+  for (size_t i = index; i < checkpoints.size()-1; i++) {
+    double latitude, longitude, altitude;
+    checkpoints.at(i+1)->GetCoordinates(&latitude, &longitude, &altitude);
+    checkpoints.at(i)->SetCoordinates(latitude,longitude,altitude);
   }
+
+  //remove last one
+  delete checkpoints.back();
+  checkpoints.pop_back();
+
+  //remove last one in xml
+  ostringstream lat_prop, long_prop, alt_prop;
+  lat_prop << "lat" << checkpoints.size();
+  long_prop << "long" << checkpoints.size();
+  alt_prop << "alt" << checkpoints.size();
+  UnsetPersistentXmlProp(lat_prop.str());
+  UnsetPersistentXmlProp(long_prop.str());
+  UnsetPersistentXmlProp(alt_prop.str());
 }
 
Index: trunk/lib/FlairCore/src/Map.h
===================================================================
--- trunk/lib/FlairCore/src/Map.h	(revision 62)
+++ trunk/lib/FlairCore/src/Map.h	(revision 67)
@@ -77,4 +77,6 @@
   void ExtraXmlEvent(void);
 
+  void removeCheckpoint(size_t index);
+
   std::vector<core::GeoCoordinate *> checkpoints;
   std::vector<const core::GeoCoordinate *> to_draw;
Index: trunk/lib/FlairCore/src/Widget.cpp
===================================================================
--- trunk/lib/FlairCore/src/Widget.cpp	(revision 62)
+++ trunk/lib/FlairCore/src/Widget.cpp	(revision 67)
@@ -82,4 +82,17 @@
   if (GetPersistentXmlProp<double>(prop, tmp)) {
     value = tmp;
+    return true;
+  } else {
+    return false;
+  }
+}
+
+template <>
+bool Widget::GetPersistentXmlProp(std::string prop, std::string &value) {
+  xmlChar *result = NULL;
+  result = xmlGetProp(pimpl_->file_node, (xmlChar *)prop.c_str());
+  if (result != NULL) {
+    value = std::string((char *)result);
+    xmlFree(result);
     return true;
   } else {
@@ -208,4 +221,13 @@
 }
 
+template <> void Widget::SetPersistentXmlProp(std::string prop, std::string value) {
+  SetVolatileXmlProp(prop, value);
+  SetVolatileXmlProp(prop, value, pimpl_->file_node);
+}
+
+void Widget::UnsetPersistentXmlProp(std::string prop) {
+  xmlUnsetProp(pimpl_->file_node, (xmlChar *)prop.c_str());
+}
+
 void Widget::SendXml(void) { pimpl_->SendXml(); }
 
Index: trunk/lib/FlairCore/src/Widget.h
===================================================================
--- trunk/lib/FlairCore/src/Widget.h	(revision 62)
+++ trunk/lib/FlairCore/src/Widget.h	(revision 67)
@@ -143,4 +143,13 @@
   virtual void XmlEvent(void){};
 
+  /*!
+   * \brief Unset a persistent xml property
+   * 
+   * Unset an existent property, so it won't be saved.
+   *
+   * \param prop property to set
+   */
+  void UnsetPersistentXmlProp(std::string prop);
+
 private:
   class Widget_impl *pimpl_;
Index: trunk/lib/FlairSensorActuator/src/NmeaGps.cpp
===================================================================
--- trunk/lib/FlairSensorActuator/src/NmeaGps.cpp	(revision 62)
+++ trunk/lib/FlairSensorActuator/src/NmeaGps.cpp	(revision 67)
@@ -195,4 +195,5 @@
   if (result != 1) {
     Warn("unrecognized nmea sentence: %s\n",frame);
+    return;
   }
 
Index: trunk/tools/FlairGCS/src/DataRemote.cpp
===================================================================
--- trunk/tools/FlairGCS/src/DataRemote.cpp	(revision 62)
+++ trunk/tools/FlairGCS/src/DataRemote.cpp	(revision 67)
@@ -78,4 +78,6 @@
 
 void DataRemote::SendPeriod(int period, bool auto_refresh) {
+  RemoveAllAttributes();
+
   SetAttribute("period", period);
   SetAttribute("enabled", auto_refresh);
Index: trunk/tools/FlairGCS/src/Landmark.cpp
===================================================================
--- trunk/tools/FlairGCS/src/Landmark.cpp	(revision 62)
+++ trunk/tools/FlairGCS/src/Landmark.cpp	(revision 67)
@@ -46,4 +46,12 @@
 }
 
+bool Landmark::IsUptodate(void) {
+  if(text->brush()==QBrush(Qt::white)) {
+    return true;
+  } else {
+    return false;
+  }
+}
+
 void Landmark::setCoordinate(const QGeoCoordinate &coordinate) {
   pixmap->setCoordinate(coordinate);
Index: trunk/tools/FlairGCS/src/Landmark.h
===================================================================
--- trunk/tools/FlairGCS/src/Landmark.h	(revision 62)
+++ trunk/tools/FlairGCS/src/Landmark.h	(revision 67)
@@ -29,4 +29,5 @@
   void RemoveLandmark(void);
   void AddLandmark(QtMobility::QGraphicsGeoMap *geoMap);
+  bool IsUptodate(void);
 
 private:
Index: trunk/tools/FlairGCS/src/Map.cpp
===================================================================
--- trunk/tools/FlairGCS/src/Map.cpp	(revision 62)
+++ trunk/tools/FlairGCS/src/Map.cpp	(revision 67)
@@ -95,6 +95,4 @@
   for (int i = 0; i < points.count(); i++) delete points.at(i);
   delete mapWidget;
-
-  if(geoMap!=0) delete geoMap;
 }
 
Index: trunk/tools/FlairGCS/src/Map.h
===================================================================
--- trunk/tools/FlairGCS/src/Map.h	(revision 62)
+++ trunk/tools/FlairGCS/src/Map.h	(revision 67)
@@ -25,4 +25,6 @@
 class Map : public DataRemote {
   Q_OBJECT
+
+  friend class MapWidget;
 
 public:
Index: trunk/tools/FlairGCS/src/XmlWidget.cpp
===================================================================
--- trunk/tools/FlairGCS/src/XmlWidget.cpp	(revision 62)
+++ trunk/tools/FlairGCS/src/XmlWidget.cpp	(revision 67)
@@ -291,4 +291,15 @@
 }
 
+void XmlWidget::RemoveAllAttributes() {
+  QString name = write_elem.attribute("name");
+
+  QDomNamedNodeMap attributes=write_elem.attributes();
+  while(attributes.count()!=0) {
+    printf("%i %s\n",attributes.count(),attributes.item(0).toAttr().name().toLocal8Bit().constData());
+    write_elem.removeAttribute(attributes.item(0).toAttr().name());
+  }
+  SetAttribute("name", name);
+}
+
 void XmlWidget::RenamedFrom(QString old_name) {
   QString name = write_elem.attribute("name");
Index: trunk/tools/FlairGCS/src/XmlWidget.h
===================================================================
--- trunk/tools/FlairGCS/src/XmlWidget.h	(revision 62)
+++ trunk/tools/FlairGCS/src/XmlWidget.h	(revision 67)
@@ -68,4 +68,5 @@
   void SetAttribute(const QString &name, float value);
   void SetAttribute(const QString &name, double value);
+  void RemoveAllAttributes(); //except name
   void RemoveAttribute(const QString &name);
 };
Index: trunk/tools/FlairGCS/src/mapwidget.cpp
===================================================================
--- trunk/tools/FlairGCS/src/mapwidget.cpp	(revision 62)
+++ trunk/tools/FlairGCS/src/mapwidget.cpp	(revision 67)
@@ -54,4 +54,5 @@
 #include "Landmark.h"
 #include "Map.h"
+#include "ConnectionLayout.h"
 
 using namespace QtMobility;
@@ -66,5 +67,4 @@
   pressed = false;
   landmark_match = NULL;
-  is_uptodate = true;
   this->map = map;
 
@@ -107,4 +107,5 @@
       QList<QAction *> centered_actions;
 
+      //add centered for every point
       QMenu *centered_menu = menu->addMenu("centered");
       for (int i = 0; i < points.count(); i++) {
@@ -122,4 +123,6 @@
 
       b = menu->addAction("place checkpoint");
+
+      //add go to for every landmark
       QMenu *go_to_menu = menu->addMenu("go to");
       for (int i = 0; i < landmarks->count(); i++) {
@@ -134,4 +137,5 @@
       z = map->execmenu(this, menu, event->globalPos());
 
+      //center to the desired point
       for (int i = 0; i < centered_actions.count(); i++) {
         if (z == centered_actions.at(i)) {
@@ -146,4 +150,5 @@
       }
 
+      //add a landmark
       if (z == b) {
         Landmark *landmark = new Landmark(
@@ -151,5 +156,4 @@
             QString("%1").arg(landmarks->count() + 1));
         landmarks->append(landmark);
-        is_uptodate = false;
       }
       for (int i = 0; i < go_to_actions.count(); i++) {
@@ -161,22 +165,45 @@
       }
 
+    //delete landmark
     } else {
       QAction *a, *z;
       a = menu->addAction("delete");
-      z = menu->exec(event->globalPos());
-
-      if (z == a) {
-        int i;
-        for (i = 0; i < landmarks->count(); i++) {
-          if (landmarks->at(i)->contains(
+      //get selected landmark id
+      int landmark_index;
+      for (landmark_index = 0; landmark_index < landmarks->count(); landmark_index++) {
+          if (landmarks->at(landmark_index)->contains(
                   geoMap->screenPositionToCoordinate(event->pos()))) {
-            delete landmarks->at(i);
-            landmarks->removeAt(i);
+            a->setEnabled(landmarks->at(landmark_index)->IsUptodate());
             break;
           }
-        }
-        for (int j = i; j < landmarks->count(); j++) {
+      }
+      z = menu->exec(event->globalPos());
+
+      if (z == a) {
+        //remove from landmarks_old
+        for (int i = 0; i < landmarks_old->count(); i++) {
+          if (landmarks_old->at(i)->contains(
+                  geoMap->screenPositionToCoordinate(event->pos()))) {
+            landmarks_old->removeAt(i);
+            break;
+          }
+        }
+
+        //remove from landmarks
+        delete landmarks->at(landmark_index);
+        landmarks->removeAt(landmark_index);
+
+        //reorder the remaining ones
+        for (int j = landmark_index; j < landmarks->count(); j++) {
           landmarks->at(j)->setText(QString("%1").arg(j + 1));
         }
+
+        //send delete
+        map->RemoveAllAttributes();
+        map->SetAttribute("lat" + QString::number(landmark_index),"delete");
+        map->SetAttribute("long" + QString::number(landmark_index),"delete");
+        map->connectionLayout()->XmlToSend(map->XmlDoc());
+        map->RemoveAttribute("lat" + QString::number(landmark_index));
+        map->RemoveAttribute("long" + QString::number(landmark_index));
       }
     }
@@ -219,5 +246,4 @@
         landmark_match = landmarks->at(i);
         landmark_match->setColor(Qt::red);
-        is_uptodate = false;
       }
       new_cursor = Qt::PointingHandCursor;
@@ -290,5 +316,10 @@
 }
 
-bool MapWidget::IsUptodate(void) { return is_uptodate; }
+bool MapWidget::IsUptodate(void) {
+  for (int i = 0; i < landmarks->count(); i++) {
+    if(!landmarks->at(i)->IsUptodate()) return false;
+  }
+  return true;
+}
 
 void MapWidget::SetUptodate(void) {
@@ -306,6 +337,4 @@
     landmarks_old->at(i)->setVisible(false);
   }
-
-  is_uptodate = true;
 }
 
@@ -323,6 +352,4 @@
     landmarks->at(i)->setColor(Qt::white);
   }
-
-  is_uptodate = true;
 }
 
Index: trunk/tools/FlairGCS/src/mapwidget.h
===================================================================
--- trunk/tools/FlairGCS/src/mapwidget.h	(revision 62)
+++ trunk/tools/FlairGCS/src/mapwidget.h	(revision 67)
@@ -94,5 +94,4 @@
   QPoint dragStartPosition;
   bool pressed;
-  bool is_uptodate;
 
   QGraphicsScene *m_scene;
