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
| // Dessiner un cargo
function RenvoyerCargo(longBateau, largBateau) {
var cargoPoint = new Array()
var cargo;
// Les points du cargo
cargoPoint.push(new OpenLayers.Geometry.Point(-largBateau/2, -longBateau/2));
cargoPoint.push(new OpenLayers.Geometry.Point(largBateau/2, -longBateau/2));
cargoPoint.push(new OpenLayers.Geometry.Point(largBateau/2, longBateau * 5 / 12));
cargoPoint.push(new OpenLayers.Geometry.Point(0, longBateau / 2));
cargoPoint.push(new OpenLayers.Geometry.Point(-largBateau/2, longBateau * 5 / 12));
cargo = new OpenLayers.Geometry.LinearRing(cargoPoint);
// On déplace le bateau pour tenir compte de la position AIS (1/6 arrière)
cargo.move(0, longBateau * 5/12);
return cargo;
}
// Renvoyer un objet Vecteur à partir de coordonnées, de cap, d'un type de bateau, d'une longueur, d'une largeur et d'infos sur le popup à générer
function RenvoyerBateauVecteur(x, y, cap, typeBateau, longBateau, largBateau, data) {
var bateau, polyBateau, bateauVecteur, style;
switch(typeBateau) {
case 'IN' : // Inconnu donc pas dans VIGIE2
bateau = RenvoyerCargo(longBateau, largBateau);
style = style_bateau_inconnu;
break;
default :
bateau = RenvoyerBateauStandard(longBateau, largBateau);
style = style_bateau;
}
// On déplace le navire
bateau.move(x, y);
// On fait tourner le navire selon son cap
bateau.rotate(360-cap, new OpenLayers.Geometry.Point(x,y));
//
bateauVecteur = new OpenLayers.Feature.Vector(bateau, data, style);
return bateauVecteur;
} |
Partager