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.domain.repository;
24  
25  import java.util.List;
26  
27  import com.gisgraphy.domain.geoloc.entity.OpenStreetMap;
28  import com.gisgraphy.domain.valueobject.StreetDistance;
29  import com.gisgraphy.street.StreetSearchMode;
30  import com.gisgraphy.street.StreetType;
31  import com.vividsolutions.jts.geom.Point;
32  
33  public interface IOpenStreetMapDao extends IDao<OpenStreetMap, java.lang.Long> {
34  
35      /**
36       * base method for all findNearest
37       * 
38       * @param point
39       *                The point from which we want to find GIS Object
40       * @param distance
41       *                The radius in meters
42       * @param firstResult
43       *                the firstResult index (for pagination), numbered from 1,
44       *                if < 1 : it will not be taken into account
45       * @param maxResults
46       *                The Maximum number of results to retrieve (for
47       *                pagination), if <= 0 : it will not be taken into acount
48       * @param streetType
49       *                The type of street
50       * @param oneWay
51       *                whether the street should be oneway or not
52       * @param name
53       *                the name the street name must contains
54       * 
55       * @param streetSearchMode if we search in fulltext or contain mode
56       * @param includeDistanceField if we have to calculate the distance or not
57       * @return A List of StreetDistance with the nearest elements or an
58       *         empty list (never return null), ordered by distance.
59       * @see StreetDistance
60       */
61      public List<StreetDistance> getNearestAndDistanceFrom(
62  	    final Point point, final double distance,
63  	    final int firstResult, final int maxResults,
64  	    final StreetType streetType,Boolean oneWay, final String name,
65  	    final StreetSearchMode streetSearchMode,
66  	    final boolean includeDistanceField) ;
67      
68      /**
69       * @param gid the gid of the openstreetmap entity we want to retrieve
70       * @return the OpenstreetMap entity or null if not found
71       */
72      public OpenStreetMap getByGid(final Long gid) ;
73      
74      /** 
75       * Update the ts_vector column for the street name search 
76       * (partial search and fulltext search)
77       * @return the number of line updated
78       * @see StreetSearchMode
79       */    
80      public Integer updateTS_vectorColumnForStreetNameSearch();
81      
82      /** 
83       * Update the ts_vector column for the street name search from the gid that are >= from and < to
84       * @param from the start pagination index of gid
85       * @param to the end pagination index 
86       * (partial search and fulltext search)
87       * @return the number of line updated
88       * @see StreetSearchMode
89       */    
90      public Integer updateTS_vectorColumnForStreetNameSearchPaginate(long from, long to ) ;
91      
92      /**
93       * Create the database GIST  for openstreetMap
94       * to improve performances
95       */
96      public void createSpatialIndexes();
97      
98      /**
99       * Create the fulltext index for openstreetMap
100      * to improve performances
101      */
102     public void createFulltextIndexes();
103     
104     
105     
106     /**
107      * @return the number of streets based on the highest gid 
108      */
109     public long countEstimate();
110 	
111     /**
112      * @param openstreetmapId the openstreetmap id (not the id, not the gid)
113      * @return the openstreetmap
114      */
115     public OpenStreetMap getByOpenStreetMapId(Long openstreetmapId);
116     
117     
118     /**
119      * @param point the point to search around
120      * @param ids the openstreetmap ids of streets we want to restrict search
121      * @return the nearest street of all the streets with the ids specified, for the given point 
122      */
123     public OpenStreetMap getNearestByosmIds(final Point point, final List<Long> ids) ;
124     
125     /**
126      * @return the highest openstreetMapId 
127      */
128     public long getMaxOpenstreetMapId();
129     
130     /**
131      * @return the highest Gid 
132      */
133     public long getMaxGid();
134     
135     /**
136      * find the nearest street based on the shape, not the middle point
137      * 
138      * @param point
139      *                The point from which we want to find street
140      */
141     public OpenStreetMap getNearestFrom(
142     	    final Point point) ;
143     
144     /**
145      * find the nearest road based on the shape, not the middle point and exclude footway
146      * 
147      * @param point
148      *                The point from which we want to find street
149      */
150     public OpenStreetMap getNearestRoadFrom(
151     	    final Point point);
152 
153     
154     /**
155      * @param point
156      * @param onlyroad 
157      * @param filterEmptyName filter street with name=null
158      * @return  the nearest street based on the shape, not the middle point
159      */
160     public OpenStreetMap getNearestFrom(
161     	    final Point point,final boolean onlyroad,boolean filterEmptyName);
162     /**
163      * @param gid the gid of the feature
164      * @return the shape as wkt
165      */
166     public String getShapeAsWKTByGId(final Long gid);
167 }