java/nekurak.net-web/src/java/cz/frantovo/nekurak/web/Detail.java
author František Kučera <franta-hg@frantovo.cz>
Wed Apr 14 00:12:32 2010 +0200 (2010-04-14)
changeset 100 01be78803f73
child 107 e8371105fcc8
permissions -rw-r--r--
Webové služby, zjišťování souřadnic podniků.
     1 package cz.frantovo.nekurak.web;
     2 
     3 import cz.frantovo.nekurak.dto.Podnik;
     4 import java.io.UnsupportedEncodingException;
     5 import java.net.URLEncoder;
     6 import java.util.logging.Level;
     7 import java.util.logging.Logger;
     8 
     9 /**
    10  *
    11  * @author fiki
    12  */
    13 public class Detail {
    14 
    15     private HledacSluzby hledac = new HledacSluzby();
    16     private int id;
    17     private Podnik podnik;
    18 
    19     /**
    20      * @return URL mapy – obrázku nebo null při chybě nebo absenci souřadnic
    21      */
    22     public String getMapa() {
    23 	Podnik p = getPodnik();
    24 
    25 	if (p == null || p.getSirka() == null || p.getDelka() == null) {
    26 	    return null;
    27 	} else {
    28 	    try {
    29 		String souradnice = URLEncoder.encode(p.getSirka() + ", " + p.getDelka(), "UTF-8");
    30 		return "http://maps.google.com/maps/api/staticmap?size=400x400&sensor=false&center=" + souradnice;
    31 	    } catch (UnsupportedEncodingException e) {
    32 		return null;
    33 	    }
    34 	}
    35     }
    36 
    37     public int getId() {
    38 	return id;
    39     }
    40 
    41     public void setId(int id) {
    42 	this.id = id;
    43     }
    44 
    45     public Podnik getPodnik() {
    46 	if (podnik == null) {
    47 	    podnik = hledac.getPodnikEJB().getPodnik(id);
    48 	}
    49 	return podnik;
    50     }
    51 }