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.webapp.action;
24  
25  import org.springframework.beans.factory.annotation.Required;
26  
27  import com.gisgraphy.domain.geoloc.entity.City;
28  import com.gisgraphy.domain.geoloc.entity.OpenStreetMap;
29  import com.gisgraphy.domain.repository.ICityDao;
30  import com.gisgraphy.domain.repository.IOpenStreetMapDao;
31  import com.opensymphony.xwork2.ActionSupport;
32  
33  /**
34   * stats Action
35   * 
36   * @author <a href="mailto:david.masclet@gisgraphy.com">David Masclet</a>
37   */
38  public class DebugStreetAction extends ActionSupport {
39  
40  	/**
41       * Default serialId
42       */
43  	private static final long serialVersionUID = -7519735359681028901L;
44  
45  	
46  
47      private OpenStreetMap openstreetmap;
48      
49      private ICityDao cityDao;
50      
51      private IOpenStreetMapDao openStreetMapDao;
52      
53      private Long openstreetmapId;
54      
55      private City nearestMunicipalityByShape;
56      
57      private City nearestNonMunicipalityByShape;
58      
59      private City nearestMunicipalityByVicinity;
60      
61      private City nearestNonMunicipalityByVicinity;
62      
63      private String message ;
64  
65    
66  
67      /*
68       * (non-Javadoc)
69       * 
70       * @see com.opensymphony.xwork2.ActionSupport#execute()
71       */
72      @Override
73      public String execute() throws Exception {
74      	if (openstreetmapId==null){
75      		return SUCCESS;
76      	} else {
77      		openstreetmap = openStreetMapDao.getByOpenStreetMapId(openstreetmapId);
78      		if (openstreetmap!=null){
79      			nearestMunicipalityByShape = cityDao.getByShape(openstreetmap.getLocation(), null, true);
80      			nearestNonMunicipalityByShape = cityDao.getByShape(openstreetmap.getLocation(), null, false);
81      			nearestMunicipalityByVicinity = cityDao.getNearest(openstreetmap.getLocation(), null, true, com.gisgraphy.importer.OpenStreetMapSimpleImporter.DISTANCE);
82      			nearestNonMunicipalityByVicinity = cityDao.getNearest(openstreetmap.getLocation(), null, false, com.gisgraphy.importer.OpenStreetMapSimpleImporter.DISTANCE);
83      			return SUCCESS;
84      		} else {
85      			message =  "No street found for "+openstreetmapId;
86      			return SUCCESS;
87      		}
88      	}
89      	
90      }
91  
92  
93  
94  	public OpenStreetMap getOpenstreetmap() {
95  		return openstreetmap;
96  	}
97  
98  
99  
100 
101 	public Long getOpenstreetmapId() {
102 		return openstreetmapId;
103 	}
104 
105 
106 
107 	public void setOpenstreetmapId(Long openstreetmapId) {
108 		this.openstreetmapId = openstreetmapId;
109 	}
110 
111 	
112 
113 	@Required
114 	public void setCityDao(ICityDao cityDao) {
115 		this.cityDao = cityDao;
116 	}
117 
118 
119 	@Required
120 	public void setOpenStreetMapDao(IOpenStreetMapDao openStreetMapDao) {
121 		this.openStreetMapDao = openStreetMapDao;
122 	}
123 
124 
125 
126 	public City getNearestMunicipalityByShape() {
127 		return nearestMunicipalityByShape;
128 	}
129 
130 
131 
132 	public City getNearestNonMunicipalityByShape() {
133 		return nearestNonMunicipalityByShape;
134 	}
135 
136 
137 
138 	public City getNearestMunicipalityByVicinity() {
139 		return nearestMunicipalityByVicinity;
140 	}
141 
142 
143 
144 	public City getNearestNonMunicipalityByVicinity() {
145 		return nearestNonMunicipalityByVicinity;
146 	}
147 
148 
149 
150 	public String getMessage() {
151 		return message;
152 	}
153 
154 
155 
156 
157 
158 
159 }