View Javadoc
1   /*******************************************************************************
2    *   Gisgraphy Project 
3    * 
4    *   This library is free software; you can redistribute it and/or
5    *   modify it under the terms of the GNU Lesser General Public
6    *   License as published by the Free Software Foundation; either
7    *   version 2.1 of the License, or (at your option) any later version.
8    * 
9    *   This library is distributed in the hope that it will be useful,
10   *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12   *   Lesser General Public License for more details.
13   * 
14   *   You should have received a copy of the GNU Lesser General Public
15   *   License along with this library; if not, write to the Free Software
16   *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
17   * 
18   *  Copyright 2008  Gisgraphy project 
19   *  David Masclet <davidmasclet@gisgraphy.com>
20   *  
21   *  
22   *******************************************************************************/
23  package com.gisgraphy.street;
24  
25  import com.gisgraphy.domain.geoloc.entity.AlternateName;
26  import com.gisgraphy.domain.geoloc.entity.AlternateOsmName;
27  import com.gisgraphy.domain.geoloc.entity.OpenStreetMap;
28  import com.gisgraphy.domain.geoloc.entity.Street;
29  
30  
31  /**
32   * Factory to create a street from an openstreetMap entity
33   * 
34   * @author <a href="mailto:david.masclet@gisgraphy.com">David Masclet</a>
35   *
36   */
37  public class StreetFactory implements IStreetFactory {
38  
39     /* (non-Javadoc)
40   * @see com.gisgraphy.domain.geoloc.service.geoloc.street.IStreetFactory#create(com.gisgraphy.domain.geoloc.entity.OpenStreetMap)
41   */
42  public Street create(OpenStreetMap openstreetmap){
43         if (openstreetmap !=null){
44  	   Street street = new Street();
45  	   street.setOpenstreetmapId(openstreetmap.getOpenstreetmapId());
46  	   street.setFeatureId(openstreetmap.getGid());
47  	   street.setName(openstreetmap.getName());
48  	   street.setLocation(openstreetmap.getLocation());
49  	   street.setCountryCode(openstreetmap.getCountryCode());
50  	   street.setStreetType(openstreetmap.getStreetType());
51  	   street.setLength(openstreetmap.getLength());
52  	   street.setOneWay(openstreetmap.isOneWay());
53  	   street.setIsIn(openstreetmap.getIsIn());
54  	   street.setIsInPlace(openstreetmap.getIsInPlace());
55  	   street.setIsInZip(openstreetmap.getIsInZip());
56  	   street.setIsInAdm(openstreetmap.getIsInAdm());
57  	   street.setFullyQualifiedAddress(openstreetmap.getFullyQualifiedAddress());
58  	   street.setPopulation(openstreetmap.getPopulation());
59  	   street.setHouseNumbers(openstreetmap.getHouseNumbers());
60  	   if (openstreetmap.getAlternateNames()!=null){
61  		   for (AlternateOsmName alternateOsmName : openstreetmap.getAlternateNames()){
62  			   street.addAlternateName(new AlternateName(alternateOsmName.getName(),alternateOsmName.getSource()));
63  			   
64  		   }
65  	   }
66  	   if (openstreetmap.getIsInCityAlternateNames()!=null){
67  			   street.addIsInCitiesAlternateNames(openstreetmap.getIsInCityAlternateNames());
68  	   }
69  	   return street;
70         }
71         return null;
72     }
73  
74  }