def _get_egrid_address(self, params): """ Returns a list with the matched EGRIDs for the given postal address. Args: params (pyramid_oereb.views.webservice.Parameter): The parameter object. Returns: list of pyramid_oereb.core.records.real_estate.RealEstateRecord: The list of all found records filtered by the passed criteria. """ postalcode = self._params.get('POSTALCODE') localisation = self._params.get('LOCALISATION') number = self._params.get('NUMBER') if postalcode and localisation and number: reader = AddressReader( Config.get_address_config().get('source').get('class'), **Config.get_address_config().get('source').get('params')) addresses = reader.read(params, localisation, int(postalcode), number) if len(addresses) == 0: raise HTTPNoContent() geometry = 'SRID={srid};{wkt}'.format(srid=Config.get('srid'), wkt=addresses[0].geom.wkt) processor = create_processor() return processor.real_estate_reader.read(params, **{'geometry': geometry}) else: raise HTTPBadRequest( 'POSTALCODE, LOCALISATION and NUMBER must be defined.')
def get_egrid_address(self): """ Returns a list with the matched EGRIDs for the given postal address. Returns: pyramid.response.Response: The `getegrid` response. """ params = Parameter('json' if self._is_json() else 'xml') postalcode = self._request.matchdict.get('postalcode') localisation = self._request.matchdict.get('localisation') number = self._request.matchdict.get('number') try: if postalcode and localisation and number: reader = AddressReader( Config.get_address_config().get('source').get('class'), **Config.get_address_config().get('source').get('params')) addresses = reader.read(params, localisation, int(postalcode), number) if len(addresses) == 0: raise HTTPNoContent() geometry = 'SRID={srid};{wkt}'.format( srid=Config.get('srid'), wkt=addresses[0].geom.wkt) records = self._real_estate_reader.read( params, **{'geometry': geometry}) response = self.__get_egrid_response__(records) else: raise HTTPBadRequest( 'POSTALCODE, LOCALISATION and NUMBER must be defined.') except HTTPNoContent as err: response = HTTPNoContent('{}'.format(err)) except HTTPBadRequest as err: response = HTTPBadRequest('{}'.format(err)) response.extras = OerebStats(service='GetEgridAddress', params={ 'postalcode': postalcode, 'localisation': localisation, 'number': number }) return response
def get_egrid_address(self): """ Returns a list with the matched EGRIDs for the given postal address. Returns: pyramid.response.Response: The `getegrid` response. """ postalcode = self._request.matchdict.get('postalcode') localisation = self._request.matchdict.get('localisation') number = self._request.matchdict.get('number') if postalcode and localisation and number: reader = AddressReader( Config.get_address_config().get('source').get('class'), **Config.get_address_config().get('source').get('params') ) addresses = reader.read(localisation, int(postalcode), number) if len(addresses) == 0: return HTTPNoContent() geometry = 'SRID={srid};{wkt}'.format(srid=Config.get('srid'), wkt=addresses[0].geom) records = self._real_estate_reader.read(**{'geometry': geometry}) return self.__get_egrid_response__(records) else: raise HTTPBadRequest('POSTALCODE, LOCALISATION and NUMBER must be defined.')