1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987
| import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.Environment;
import android.os.SystemClock;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Chronometer;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.example.pcdequentin.database.Station;
import com.example.pcdequentin.database.StationDatabase;
import com.example.pcdequentin.database.TachyPoint;
import com.example.pcdequentin.database.TachyPointDatabase;
import com.example.pcdequentin.database.TopoPoint;
import com.example.pcdequentin.database.TopoPointDatabase;
import org.osmdroid.DefaultResourceProxyImpl;
import org.osmdroid.ResourceProxy;
import org.osmdroid.api.IMapController;
import org.osmdroid.bonuspack.overlays.Polyline;
import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapController;
import org.osmdroid.views.MapView;
import org.osmdroid.views.overlay.ItemizedIconOverlay;
import org.osmdroid.views.overlay.OverlayItem;
import org.osmdroid.views.overlay.PathOverlay;
import org.osmdroid.views.overlay.SimpleLocationOverlay;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class Map extends Activity implements LocationListener {
private TextView montexte = null; // display coordinates
private RelativeLayout layout = null;
private MapView mMapView; // OSM map
private IMapController mMapController; // Controller to interact with the OSM view
private double aLatitude, aLongitude; // coordinates
private PathOverlay pathOverlay; // OSM view overlay that displays current path
private SimpleLocationOverlay locationOverlay; // overlays that display current location
public boolean station = false;
public boolean speed = false;
public boolean traction = false;
public Chronometer chronometer;
public ItemizedIconOverlay<OverlayItem> myLocationOverlay;
public ItemizedIconOverlay<OverlayItem> myLocationOverlayfeu;
public ItemizedIconOverlay<OverlayItem> myLocationOverlayslt;
public ItemizedIconOverlay<OverlayItem> myLocationOverlaydir;
public ItemizedIconOverlay<OverlayItem> myLocationOverlayrtrac;
public ItemizedIconOverlay<OverlayItem> myLocationOverlayctrac;
public Polyline p;
public ArrayList<GeoPoint> mTrace;
public boolean go;
public boolean loc = false;
public GeoPoint gPt;
public ArrayList<OverlayItem> overlayfeu = new ArrayList<OverlayItem>();
public ArrayList<OverlayItem> overlayslt = new ArrayList<OverlayItem>();
public ArrayList<OverlayItem> overlaydir = new ArrayList<OverlayItem>();
public ArrayList<OverlayItem> overlayrtrac = new ArrayList<OverlayItem>();
public ArrayList<OverlayItem> overlayctrac = new ArrayList<OverlayItem>();
TopoPointDatabase TopoPointDatabase = new TopoPointDatabase(this);
TachyPointDatabase TachyPointDatabase = new TachyPointDatabase(this);
TachyPoint tachy;
int vitesselim = 30;
String Releve;
private StationDatabase datasource;
ArrayAdapter<String> adapter;
////// // $$$$$$$$ A RAJOUTER $$$$$$$$$$
private TopoPointDatabase datasource_topo;
private TachyPointDatabase datasource_tachy;
private String texte_a_envoyer;
private File mFile = null;
//////////// //$$$$$$$$$$$$$$$$$
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
layout = (RelativeLayout) RelativeLayout.inflate(this, R.layout.activity_map, null);
go=false;
setContentView(layout);
// OSM map
initiateOSMView();
LocationManager locationManager = (LocationManager)getSystemService(LOCATION_SERVICE); // Access to ACCESS_FINE_LOCATION
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 5, this);// Get the actual location, every 5 seconds or 5 meters
p = new Polyline(mMapView.getContext());
p.setColor(0xAAFF3300);
p.setWidth(5.0f);
mTrace = new ArrayList<GeoPoint>();
setResult(0); // Destruction de l'activity précédente
// Toasts
final Toast toast = Toast.makeText(this, "Station ajoutée", Toast.LENGTH_SHORT);
final Toast toast2 = Toast.makeText(this, "Attendez la localisation", Toast.LENGTH_SHORT);
final Toast toast3 = Toast.makeText(this, "Station ajoutée", Toast.LENGTH_SHORT);
final Toast toast4 = Toast.makeText(this, "Feu ajouté", Toast.LENGTH_SHORT);
final Toast toast5 = Toast.makeText(this, "Signalisation lumineuse ajoutée", Toast.LENGTH_SHORT);
final Toast toast6 = Toast.makeText(this, "Signal de direction ajouté", Toast.LENGTH_SHORT);
final Toast toast7 = Toast.makeText(this, "Signal coupé traction ajouté", Toast.LENGTH_SHORT);
final Toast toast8 = Toast.makeText(this, "Signal rétablir traction ajouté", Toast.LENGTH_SHORT);
final Toast toast9 = Toast.makeText(this, "Fichier créé", Toast.LENGTH_SHORT);
final ListView list = (ListView) findViewById(R.id.listView_stations_map);
final EditText edit_station = (EditText) findViewById(R.id.editText_station);
final Button creer = (Button) findViewById(R.id.creer_station_map);
datasource = new StationDatabase(this);
datasource_tachy = new TachyPointDatabase(this);
datasource_topo = new TopoPointDatabase(this);
datasource.open();
datasource_tachy.open();
datasource_topo.open();
Bundle extras = getIntent().getExtras();
if (extras != null) {
Releve = extras.getString("Releve");
}
/////////// // $$$$$$$$ A RAJOUTER $$$$$$$$$$
mFile = new File(Environment.getExternalStorageDirectory().getPath() + "/Android/" + Releve + ".txt");
///////// //$$$$$$$$$$$$$$$$$$$$$
List<String> values = datasource.getStationWithReleve(Releve);
adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, values);
list.setAdapter(adapter);
// ListView Item Click Listener
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
String name =adapter.getItem(position);
long time2 = (SystemClock.elapsedRealtime() - chronometer.getBase())/1000;
Station station = new Station();
datasource.open();
station = datasource.getStationWithName(name);
station.setLatitude(aLatitude);
station.setLongitude(aLongitude);
station.setTime(time2);
//datasource.add(station);
datasource.update(station);
datasource.close();
overlayrtrac.add(new OverlayItem("New Overlay", "Overlay Description", gPt));
ResourceProxy resourceProxyrtrac = new DefaultResourceProxyImpl(getApplicationContext());
myLocationOverlayrtrac = new ItemizedIconOverlay<OverlayItem>(overlayrtrac,getResources().getDrawable(R.drawable.stationsmall), null, resourceProxyrtrac);
mMapView.getOverlays().add(myLocationOverlayrtrac);
toast3.show();
}
});
// The Button which allows you to fill the different parameters
final Button Button_set = (Button) findViewById(R.id.button_set);
Button_set.setOnClickListener(new View.OnClickListener() {
// Déclaration de l'intent qui nous dirigera vers la page d'accueil
public void onClick(View v) {
Intent intent = new Intent(Map.this, Fill.class); // Activity actuelle vers activity de destination
startActivity(intent);
}
});
creer.setOnClickListener(new View.OnClickListener() {
// Déclaration de l'intent qui nous dirigera vers la page d'accueil
public void onClick(View v) {
String NomStation = edit_station.getText().toString();
Station new_station = new Station();
new_station.setName(NomStation);
new_station.setNomreleve(Releve);
datasource.add(new_station);
List<String> values2 = datasource.getStationWithReleve(Releve);
adapter = new ArrayAdapter<String>(getApplicationContext(),
android.R.layout.simple_list_item_1, values2);
list.setAdapter(adapter);
toast.show();
}
});
// Button GO, start the timer
final Button Button_go = (Button) findViewById(R.id.button_go);
Button_go.setOnClickListener(new View.OnClickListener() {
// Intent which directs you to the following activity
public void onClick(View v) {
if (!loc){
Context context = getApplicationContext();
toast2.show();
}
if (loc){
go=true;
final RelativeLayout MainButtons = (RelativeLayout) findViewById(R.id.menu_button);
chronometer = (Chronometer) findViewById(R.id.chronometer);
Button_go.setVisibility(View.GONE);
Button_set.setVisibility(View.GONE);
chronometer.setBase(SystemClock.elapsedRealtime());
chronometer.start();
MainButtons.setVisibility(View.VISIBLE);}
}
});
// Button limit, we display all the different existent limits
final Button Limit = (Button) findViewById(R.id.button_limit);
Limit.setOnClickListener(new View.OnClickListener() {
// It shows the menu for the speed limits
public void onClick(View v) {
final LinearLayout MenuSpeed = (LinearLayout) findViewById(R.id.speed_menu_1);
final LinearLayout MenuSpeed_2 = (LinearLayout) findViewById(R.id.speed_menu_2);
final LinearLayout MenuStation = (LinearLayout) findViewById(R.id.menu_station);
final LinearLayout MenuTraction = (LinearLayout) findViewById(R.id.traction_menu);
if (speed == false){
speed = true;
MenuSpeed.setVisibility(View.VISIBLE);
MenuSpeed_2.setVisibility(View.VISIBLE);
if(station == true){
MenuStation.setVisibility(View.INVISIBLE);
station=false;
}
if(traction == true){
MenuTraction.setVisibility(View.INVISIBLE);
station=false;
}
}else{
speed=false;
MenuSpeed.setVisibility(View.INVISIBLE);
MenuSpeed_2.setVisibility(View.INVISIBLE);
}
}
});
final Button button_rtraction = (Button) findViewById(R.id.button_rtraction);
button_rtraction.setOnClickListener(new View.OnClickListener() {
// It shows the menu for the speed limits
public void onClick(View v) {
final LinearLayout MenuSpeed = (LinearLayout) findViewById(R.id.speed_menu_1);
final LinearLayout MenuSpeed_2 = (LinearLayout) findViewById(R.id.speed_menu_2);
final LinearLayout MenuStation = (LinearLayout) findViewById(R.id.menu_station);
final LinearLayout MenuTraction = (LinearLayout) findViewById(R.id.traction_menu);
if (traction == false){
traction = true;
MenuTraction.setVisibility(View.VISIBLE);
if(speed == true){
MenuSpeed.setVisibility(View.INVISIBLE);
MenuSpeed_2.setVisibility(View.INVISIBLE);
speed=false;
}
if(station == true){
MenuStation.setVisibility(View.INVISIBLE);
station=false;
}
}else{
traction=false;
MenuTraction.setVisibility(View.INVISIBLE);
}
}
});
final Button button_rtraction2 = (Button) findViewById(R.id.button_rtraction2);
button_rtraction2.setOnClickListener(new View.OnClickListener() {
// It shows the menu for the speed limits
public void onClick(View v) {
String type = "Remettre traction";
long time2 = (SystemClock.elapsedRealtime() - chronometer.getBase())/1000;
TopoPoint rtrac = new TopoPoint(type, aLatitude, aLongitude, time2, Releve);
TopoPointDatabase.open();
TopoPointDatabase.add(rtrac);
try {
overlayrtrac.add(new OverlayItem("New Overlay", "Overlay Description", gPt));
ResourceProxy resourceProxyrtrac = new DefaultResourceProxyImpl(getApplicationContext());
myLocationOverlayrtrac = new ItemizedIconOverlay<OverlayItem>(overlayrtrac, getResources().getDrawable(R.drawable.rtraction2), null, resourceProxyrtrac);
mMapView.getOverlays().add(myLocationOverlayrtrac);
}catch(IndexOutOfBoundsException e){
e.printStackTrace();
}
toast8.show();
// Ajout de la signalisation lumineuse de trafic dans la base de donnee
}
});
final Button button_ctraction = (Button) findViewById(R.id.button_ctraction);
button_ctraction.setOnClickListener(new View.OnClickListener() {
// It shows the menu for the speed limits
public void onClick(View v) {
int idline = '0';
String type = "Couper traction";
String description = " ";
long time2 = (SystemClock.elapsedRealtime() - chronometer.getBase())/1000;
TopoPoint ctrac = new TopoPoint(type, aLatitude, aLongitude, time2, Releve);
TopoPointDatabase.open();
TopoPointDatabase.add(ctrac);
try{
overlayctrac.add(new OverlayItem("New Overlay", "Overlay Description", gPt));
ResourceProxy resourceProxyctrac = new DefaultResourceProxyImpl(getApplicationContext());
myLocationOverlayctrac = new ItemizedIconOverlay<OverlayItem>(overlayctrac,getResources().getDrawable(R.drawable.ctraction2), null, resourceProxyctrac);
mMapView.getOverlays().add(myLocationOverlayctrac);
}catch(IndexOutOfBoundsException e){
e.printStackTrace();
}
toast7.show();
// Ajout de la signalisation lumineuse de trafic dans la base de donnee
}
});
// Button station
final Button Station = (Button) findViewById(R.id.button_station);
Station.setOnClickListener(new View.OnClickListener() {
// It shows the menu for the station selection
public void onClick(View v) {
final LinearLayout MenuStation = (LinearLayout) findViewById(R.id.menu_station);
final LinearLayout MenuSpeed = (LinearLayout) findViewById(R.id.speed_menu_1);
final LinearLayout MenuSpeed_2 = (LinearLayout) findViewById(R.id.speed_menu_2);
final LinearLayout MenuTraction = (LinearLayout) findViewById(R.id.traction_menu);
if (station==false){
station=true;
MenuStation.setVisibility(View.VISIBLE);
if(speed==true){
MenuSpeed.setVisibility(View.INVISIBLE);
MenuSpeed_2.setVisibility(View.INVISIBLE);
speed=false;
}
if(traction == true){
MenuTraction.setVisibility(View.INVISIBLE);
traction=false;
}
}else{
station=false;
MenuStation.setVisibility(View.INVISIBLE);
}
}
});
final Button feub = (Button) findViewById(R.id.button_feub);
feub.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
int idline = '0';
String type = "SLT";
String description = " ";
long time2 = (SystemClock.elapsedRealtime() - chronometer.getBase())/1000;
TopoPoint slt = new TopoPoint(type, aLatitude, aLongitude, time2, Releve);
TopoPointDatabase.open();
TopoPointDatabase.add(slt);
try{
overlayslt.add(new OverlayItem("New Overlay", "Overlay Description", gPt));
ResourceProxy resourceProxyfeub = new DefaultResourceProxyImpl(getApplicationContext());
myLocationOverlayslt = new ItemizedIconOverlay<OverlayItem>(overlayslt,getResources().getDrawable(R.drawable.feub2), null, resourceProxyfeub);
mMapView.getOverlays().add(myLocationOverlayslt);
}catch(IndexOutOfBoundsException e){
e.printStackTrace();
}
toast5.show();
// Ajout de la signalisation lumineuse de trafic dans la base de donnee
}
});
final Button feu = (Button) findViewById(R.id.button_feu);
feu.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
String type = "FEU";
long time2 = (SystemClock.elapsedRealtime() - chronometer.getBase())/1000;
TopoPoint feu = new TopoPoint(type, aLatitude, aLongitude, time2, Releve);
TopoPointDatabase.open();
TopoPointDatabase.add(feu);
try{
overlayfeu.add(new OverlayItem("New Overlay", "Overlay Description", gPt));
ResourceProxy resourceProxyfeu = new DefaultResourceProxyImpl(getApplicationContext());
myLocationOverlayfeu = new ItemizedIconOverlay<OverlayItem>(overlayfeu,getResources().getDrawable(R.drawable.feu2), null, resourceProxyfeu);
mMapView.getOverlays().add(myLocationOverlayfeu);
}catch(IndexOutOfBoundsException e){
e.printStackTrace();
}
toast4.show();
}
});
final Button direction = (Button) findViewById(R.id.button_manoeuvre);
direction.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
int idline = '0';
String type = "Signal de direction";
String description = " ";
long time2 = (SystemClock.elapsedRealtime() - chronometer.getBase())/1000;
TopoPoint dir = new TopoPoint(type, aLatitude, aLongitude, time2, Releve);
TopoPointDatabase.open();
TopoPointDatabase.add(dir);
try{
overlaydir.add(new OverlayItem("New Overlay", "Overlay Description", gPt));
ResourceProxy resourceProxydir = new DefaultResourceProxyImpl(getApplicationContext());
myLocationOverlaydir = new ItemizedIconOverlay<OverlayItem>(overlaydir,getResources().getDrawable(R.drawable.direction2), null, resourceProxydir);
mMapView.getOverlays().add(myLocationOverlaydir);
}catch(IndexOutOfBoundsException e){
e.printStackTrace();
}
toast6.show();
}
});
final Button fin = (Button) findViewById(R.id.button_end);
fin.setOnClickListener(new View.OnClickListener() {
// It shows the menu for the speed limits
public void onClick(View v) {
Intent intent = new Intent(Map.this, MesStations.class); //Lancer l'activit� DisplayVue
startActivity(intent); //Afficher la vue
}
});
final Button fin2 = (Button) findViewById(R.id.button_end2);
fin2.setOnClickListener(new View.OnClickListener() {
// It shows the menu for the speed limits
public void onClick(View v) {
Intent intent = new Intent(Map.this, MyTopoPoints.class); //Lancer l'activit� DisplayVue
startActivity(intent); //Afficher la vue
}
});
final Button fin3 = (Button) findViewById(R.id.button_end3);
fin3.setOnClickListener(new View.OnClickListener() {
// It shows the menu for the speed limits
public void onClick(View v) {
//Intent intent = new Intent(Map.this, MesStations.class); //Lancer l'activit� DisplayVue
// startActivity(intent); //Afficher la vue
///////////////////////////// A RAJOUTER $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
try {
String eol = System.getProperty("line.separator");
FileOutputStream output = openFileOutput(Releve, MODE_PRIVATE);
// Flux externe
// Si le fichier est lisible et qu'on peut écrire dedans
if(Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
&& !Environment.MEDIA_MOUNTED_READ_ONLY.equals(Environment.getExternalStorageState())) {
// On crée un nouveau fichier. Si le fichier existe déjà, il ne sera pas créé
// Création du Fichier GPX ou XML
mFile.createNewFile();
output = new FileOutputStream(mFile);
// Stations
List<Station> values = datasource.getAllCommentsWithReleve(Releve);
for (int i = 0; i<values.size();i++){
texte_a_envoyer = "<station>"
+ eol + " <id_station>"
+ eol + " " + values.get(i).getId()
+ eol + " </id_station>"
+ eol + " <name>"
+ eol + " " + values.get(i).getName()
+ eol + " </name>"
+ eol + " <nom_releve>"
+ eol + " " + values.get(i).getNomreleve()
+ eol + " </nom_releve>"
+ eol + " <latitude_station>"
+ eol + " " + values.get(i).getLatitude()
+ eol + " </latitude_station>"
+ eol + " <longitude_station>"
+ eol + " " + values.get(i).getLongitude()
+ eol + " </longitude_station>"
+ eol + " <timer_station>"
+ eol + " " + values.get(i).getTime()
+ eol + " </timer_station>"
+ eol +"</station>" + eol;
output.write(texte_a_envoyer.getBytes());
}
// TopoPoints
List<TopoPoint> values_topo = datasource_topo.getAllCommentsWithReleve(Releve);
for (int i = 0; i<values_topo.size();i++){
texte_a_envoyer = "<topopoint>"
+ eol + " <id_point>"
+ eol + " " + values_topo.get(i).getId()
+ eol + " </id_point>"
+ eol + " <type>"
+ eol + " " + values_topo.get(i).getType()
+ eol + " </type>"
+ eol + " <nom_releve>"
+ eol + " " + values_topo.get(i).getNomreleve()
+ eol + " </nom_releve>"
+ eol + " <latitude_point>"
+ eol + " " + values_topo.get(i).getLatitude()
+ eol + " </latitude_point>"
+ eol + " <longitude_point>"
+ eol + " " + values_topo.get(i).getLongitude()
+ eol + " </longitude_point>"
+ eol + " <timer_point>"
+ eol + " " + values_topo.get(i).getTimer()
+ eol + " </timer_point>"
+ eol +"</topopoint>" + eol;
output.write(texte_a_envoyer.getBytes());
}
// TopoPoints
List<TachyPoint> values_tachy = datasource_tachy.getAllCommentsWithReleve(Releve);
for (int i = 0; i<values_tachy.size();i++){
texte_a_envoyer = "<tachypoint>"
+ eol + " <id_tachy>"
+ eol + " " + values_tachy.get(i).getId()
+ eol + " </id_tachy>"
+ eol + " <vitesse>"
+ eol + " " + values_tachy.get(i).getVitesselim()
+ eol + " </vitesse>"
+ eol + " <nom_releve>"
+ eol + " " + values_tachy.get(i).getNomreleve()
+ eol + " </nom_releve>"
+ eol + " <latitude_tachy>"
+ eol + " " + values_tachy.get(i).getLatitude()
+ eol + " </latitude_tachy>"
+ eol + " <longitude_tachy>"
+ eol + " " + values_tachy.get(i).getLongitude()
+ eol + " </longitude_tachy>"
+ eol + " <timer_tachy>"
+ eol + " " + values_tachy.get(i).getTime()
+ eol + " </timer_tachy>"
+ eol +"</tachypoint>" + eol;
output.write(texte_a_envoyer.getBytes());
}
if(output != null)
output.close();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
///////////////////////////$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
});
final Button limit15 = (Button) findViewById(R.id.button_15);
limit15.setOnClickListener(new View.OnClickListener() {
// It shows the menu for the speed limits
public void onClick(View v) {
Limit.setText("15");
vitesselim = 15;
}
});
final Button limit30 = (Button) findViewById(R.id.button_30);
limit30.setOnClickListener(new View.OnClickListener() {
// It shows the menu for the speed limits
public void onClick(View v) {
Limit.setText("30");
vitesselim = 30;
}
});
final Button limit40 = (Button) findViewById(R.id.button_40);
limit40.setOnClickListener(new View.OnClickListener() {
// It shows the menu for the speed limits
public void onClick(View v) {
Limit.setText("40");
vitesselim = 40;
}
});
final Button limit45 = (Button) findViewById(R.id.button_45);
limit45.setOnClickListener(new View.OnClickListener() {
// It shows the menu for the speed limits
public void onClick(View v) {
Limit.setText("45");
vitesselim = 45;
}
});
final Button limit50 = (Button) findViewById(R.id.button_50);
limit50.setOnClickListener(new View.OnClickListener() {
// It shows the menu for the speed limits
public void onClick(View v) {
Limit.setText("50");
vitesselim = 50;
}
});
final Button limit60 = (Button) findViewById(R.id.button_60);
limit60.setOnClickListener(new View.OnClickListener() {
// It shows the menu for the speed limits
public void onClick(View v) {
Limit.setText("60");
vitesselim = 60;
}
});
final Button limit70 = (Button) findViewById(R.id.button_70);
limit70.setOnClickListener(new View.OnClickListener() {
// It shows the menu for the speed limits
public void onClick(View v) {
Limit.setText("70");
vitesselim = 70;
}
});
final Button limit80 = (Button) findViewById(R.id.button_80);
limit80.setOnClickListener(new View.OnClickListener() {
// It shows the menu for the speed limits
public void onClick(View v) {
Limit.setText("80");
vitesselim = 80;
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
//getMenuInflater().inflate(R.menu.menu_map, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
//int id = item.getItemId();
//noinspection SimplifiableIfStatement
//if (id == R.id.action_settings) {
return true;
//}
//return super.onOptionsItemSelected(item);
}
@Override
public void onLocationChanged(Location location) {
loc = true;
Log.d("GPS", "Latitude " + location.getLatitude() + " et longitude " + location.getLongitude());
montexte = (TextView)findViewById(R.id.coordinate);
montexte.setText("Latitude " + location.getLatitude() + " et longitude " + location.getLongitude());
aLatitude = location.getLatitude();
aLongitude = location.getLongitude();
// Display OSM Map
gPt = new GeoPoint(aLatitude, aLongitude);
mMapController.setCenter(gPt);
mMapView.invalidate();
// Enregistrement des Tachypoints
if(go==true) {
long time = (SystemClock.elapsedRealtime() - chronometer.getBase())/1000;
tachy=new TachyPoint(time, aLatitude, aLongitude, vitesselim, Releve);
TachyPointDatabase.open();
TachyPointDatabase.add(tachy);
mTrace.add(new GeoPoint(aLatitude, aLongitude));
p.setPoints(mTrace);
mMapView.getOverlays().add(p);
}
ArrayList<OverlayItem> overlays = new ArrayList<OverlayItem>();
overlays.add(new OverlayItem("New Overlay", "Overlay Description", gPt));
ResourceProxy resourceProxy = new DefaultResourceProxyImpl(getApplicationContext());
if(myLocationOverlay!=null){
myLocationOverlay.removeAllItems();
}
myLocationOverlay = new ItemizedIconOverlay<OverlayItem>(overlays,getResources().getDrawable(R.drawable.point_orange), null, resourceProxy);
mMapView.getOverlays().add(myLocationOverlay);
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onProviderDisabled(String provider) {
}
public void initiateOSMView() {
mMapView = (MapView)findViewById(R.id.mapview);
mMapView.setMultiTouchControls(true); // pinch to zoom
mMapController = mMapView.getController();
mMapView.setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE);
mMapController.setZoom(19);
GeoPoint mapCenter = new GeoPoint(48.856614, 2.352222);
mMapController.setCenter(mapCenter);
}
} |
Partager