Community of VE/MapPoint Users and Developers
This is a discussion on Find address given hotel name and city within the MapPoint Web Service and Virtual Earth forums, part of the Map Forums category; Hello, How to retrieve address of a hotel given - city and hotel name using mappoint? For e.g. If I ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| How to retrieve address of a hotel given - city and hotel name using mappoint? For e.g. If I know the hotel name is "Seaport Hotel, Boston, MA", how do I get the well formed address using mappoint? Thank you. Jayati |
| |||
| Re: Find address given hotel name and city
OK Here is my take....This is a working example using the sample datasource - "MapPoint.FourthCoffeeSample" /** * Calls map point web service and returns a list of matched addresses for * the address given. * * @param addressString - * the address String passed * @return - the list of matched addresses. */ public List List /************************************************** ********************* * the Stub ************************************************** ********************/ FindServiceStub stub = null; try { stub = new FindServiceStub(); /************************************************** ***************** * Authentication ************************************************** ****************/ HttpTransportProperties.ProxyProperties proxyProperties = new HttpTransportProperties.ProxyProperties(); //***Set the authentication - username, password, proxy name, proxy port, etc /************************************************** ***************** * ServiceClient connection options ************************************************** ****************/ Options options = stub._getServiceClient().getOptions(); options.setProperty(HTTPConstants.AUTHENTICATE, auth); //***set option properties such as timeout, connection timeout,proxy, etc // -- set the EndpointReference (the FindServicURL) EndpointReference endpoint = new EndpointReference( "http://findv3.staging.mappoint.net/F...ndService.asmx"); options.setTo(endpoint); // stub. FindFilter findFilter = new FindFilter(); FindByProperty findByProperty = new FindByProperty(); try { findFilter.setEntityTypeName("FourthCoffeeShops"); WhereClause whereClause = new WhereClause(); ArrayOfEntityPropertyValue arrayOfEntityPropertyValue = new ArrayOfEntityPropertyValue(); org.apache.axiom.om.OMFactory fac1 = org.apache.axiom.om.OMAbstractFactory.getOMFactory (); org.apache.axiom.om.OMNamespace omNs1 = fac1.createOMNamespace("http://s.mappoint.net/mappoint-30/", ""); // Setup the where clause EntityPropertyValue entityPropertyValue1 = new EntityPropertyValue(); EntityPropertyValue entityPropertyValue2 = new EntityPropertyValue(); entityPropertyValue2.setName("Subdivision"); org.apache.axiom.om.OMElement _value2 = fac1.createOMElement("MA", omNs1); entityPropertyValue1.setValue(_value2); arrayOfEntityPropertyValue.addProperty(entityPrope rtyValue2); SearchOperatorFlag searchOperatorFlag = whereClause.getSearchOperator(); whereClause.setSearchOperator(SearchOperatorFlag.A nd); whereClause.setSearchProperties(arrayOfEntityPrope rtyValue); findFilter.setWhereClause(whereClause); FindByPropertySpecification findByPropertySpecification = new FindByPropertySpecification(); findByPropertySpecification.setFilter(findFilter); findByPropertySpecification.setDataSourceName("MapPoint.FourthCoffeeSample"); FindRange findRange = new FindRange(); findRange.setCount(new Integer(20)); // Return 20 results FindOptions findOptions = new FindOptions(); findOptions.setRange(findRange); FindResultMask findResultMask = new FindResultMask(); findOptions.setResultMask(findResultMask); findByPropertySpecification.setOptions(findOptions ); findByProperty.setSpecification(findByPropertySpec ification); FindByPropertyResponse response = stub.FindByProperty( findByProperty, null, null); FindResults results = response.getFindByPropertyResult(); if (results.getNumberFound() > 0) { ArrayOfFindResult arrayOfFindResults = results.getResults(); FindResult[] thearray = arrayOfFindResults.getFindResult(); FindResult findresult = null; Location location = null; ReservationAddress reservationAddress = null; for (int i = 0; i < thearray.length; i++) { findresult = (FindResult) thearray[i]; if (findresult != null) { location = findresult.getFoundLocation(); } reservationAddress = new ReservationAddress(); if (location.getEntity().getDisplayName() != null) { reservationAddress.setLocalDisplayName(findresult .getFoundLocation().getEntity() .getDisplayName()); matchedAddressesList.add(reservationAddress); } } } } catch (RemoteException e) { // handle the exception System.out.println("Exception occured" + e.getMessage()); } } catch (AxisFault e) { // handle the exception System.out.println(e.getMessage()); } return matchedAddressesList; } |
| |||
| Re: Find address given hotel name and city
If I use the sample datasource, the findFilter works, if I use a different datasource - MapPoint.NA this doesn't work. I found a work around. I have used Find to get the longitude, latitude of lets say the Boston, MA. Then I use the FindNearBy to search for the required landMark, to get the address, loop through the list of addresss and look for the matching display name. I had a hard time researching this, i haven't found any helpful post, so here is my contribution. If you have a DIFFERENT and BETTER approach, please add your reply to this post. /** * findLandmarkAddress. * @param addressString - addressString * @param filter - entityTypeName filter * @param displayName - display name of entityType * @return {@link ReservationAddress} */ public List final String addressString, final String filter, final String displayName) { List AddressLatLongParams latLongValue = new AddressLatLongParams(); Address addressFound = new Address(); /************************************************** ********************* * the Stub ************************************************** ********************/ FindServiceStub stub = null; try { stub = new FindServiceStub(); /************************************************** ***************** * Authentication ************************************************** ****************/ HttpTransportProperties.ProxyProperties proxyProperties = new HttpTransportProperties.ProxyProperties(); //***Set the authentication - username, password,etc /************************************************** ***************** * ServiceClient connection options ************************************************** ****************/ Options options = stub._getServiceClient().getOptions(); options.setProperty(HTTPConstants.AUTHENTICATE, auth); //***set option properties such as timeout, connection timeout,proxy, etc // -- set the EndpointReference (the FindServicURL) EndpointReference endpoint = new EndpointReference( "http://findv3.staging.mappoint.net/F...ndService.asmx"); options.setTo(endpoint); //stub Find find = new Find(); try { // Create find specification FindSpecification findSpecification = new FindSpecification(); // Define find by property specification findSpecification.setDataSourceName("MapPoint.NA"); findSpecification.setInputPlace(addressString); find.setSpecification(findSpecification); FindResponse response = stub.Find(find, null, null); FindResults results = response.getFindResult(); if (results.getNumberFound() > 0) { ArrayOfFindResult arrayOfFindResults = results.getResults(); FindResult[] thearray = arrayOfFindResults.getFindResult(); FindResult findresult = null; Location location = null; ReservationAddress reservationAddress = null; for (int i = 0; i < thearray.length; i++) { findresult = (FindResult) thearray[i]; if (findresult != null) { location = findresult.getFoundLocation(); latLongValue.setLatitude(location.getLatLong().get Latitude()); latLongValue.setLongitude(location.getLatLong().ge tLongitude()); } reservationAddress = new ReservationAddress(); System.out.println(findresult.getFoundLocation().g etEntity().getDisplayName().toString()); if (reservationAddress != null && findresult.getFoundLocation().getEntity().getDispl ayName().toString().equalsIgnoreCase(displayName)) { reservationAddress = getAddress(latLongValue, filter, displayName); matchedAddressesList.add(reservationAddress); } } } } catch (RemoteException e) { // handle the exception System.out.println("Exception occured"); } } catch (AxisFault e) { // handle the exception System.out.println(e.getMessage()); } return matchedAddressesList; } /** * getAddress. * * @param addressLatLongParams - lat long parameters of an address * @param filter - entity type filter * @param displayName - display name * @return ReservationAddress - the list of nearby addresses of * interest. */ public ReservationAddress getAddress( final AddressLatLongParams addressLatLongParams, final String filter, final String displayName) { ReservationAddress matchedAddressesList = new ReservationAddress(); /************************************************** ********************* * the Stub ************************************************** ********************/ FindServiceStub stub = null; try { stub = new FindServiceStub(); /************************************************** ***************** * Authentication ************************************************** ****************/ HttpTransportProperties.ProxyProperties proxyProperties = new HttpTransportProperties.ProxyProperties(); //***Set the authentication - username, password,etc /************************************************** ***************** * ServiceClient connection options ************************************************** ****************/ Options options = stub._getServiceClient().getOptions(); options.setProperty(HTTPConstants.AUTHENTICATE, auth); //***set option properties such as timeout, connection timeout,proxy, etc // -- set the EndpointReference (the FindServicURL) EndpointReference endpoint = new EndpointReference( "http://findv3.staging.mappoint.net/F...ndService.asmx"); options.setTo(endpoint); // stub. FindNearby findNearBy = new FindNearby(); try { FindNearbySpecification findNearbySpec = new FindNearbySpecification(); findNearbySpec.setDataSourceName("NavTech.NA"); FindFilter findFilter = new FindFilter(); // findFilter.setEntityTypeName("SIC3578"); //ATMs nearby findFilter.setEntityTypeName(filter); // findFilter.setEntityTypeName("FourthCoffeeShops"); // //"FourthCoffeeShops"); findNearbySpec.setDistance(180); findNearbySpec.setFilter(findFilter); LatLong latLong = new LatLong(); if (addressLatLongParams != null) { latLong.setLatitude(addressLatLongParams.getLatitu de()); latLong.setLongitude(addressLatLongParams.getLongi tude()); findNearbySpec.setLatLong(latLong); findNearBy.setSpecification(findNearbySpec); FindNearbyResponse response = stub.FindNearby(findNearBy, null, null); FindResults results = response.getFindNearbyResult(); if (results.getNumberFound() > 0) { ArrayOfFindResult arrayOfFindResults = results .getResults(); FindResult[] thearray = arrayOfFindResults .getFindResult(); Address addressFound = null; FindResult findresult = null; Location location = null; for (int i = 0; i < thearray.length; i++) { findresult = (FindResult) thearray[i]; if (findresult != null) { location = findresult.getFoundLocation(); } addressFound = location.getAddress(); System.out.println(findresult.getFoundLocation().g etEntity().getDisplayName().toString()); if (addressFound != null && findresult.getFoundLocation().getEntity().getDispl ayName().toString().equalsIgnoreCase(displayName)) { matchedAddressesList.setAddressLine(addressFound .getAddressLine()); matchedAddressesList .setFormattedAddress(addressFound .getFormattedAddress()); matchedAddressesList.setCity(addressFound .getPrimaryCity()); matchedAddressesList.setCountry(addressFound .getCountryRegion()); matchedAddressesList.setPostalCode(addressFound .getPostalCode()); matchedAddressesList.setState(addressFound .getSubdivision()); matchedAddressesList.setScore(findresult .getScore()); matchedAddressesList .setLocalDisplayName(findresult .getFoundLocation().getEntity() .getDisplayName()); ; } } } } } catch (RemoteException e) { // handle the exception System.out.println("Exception occured" + e.getMessage()); } } catch (AxisFault e) { // handle the exception System.out.println(e.getMessage()); } return matchedAddressesList; } |
![]() |
| Tags |
| address, city, find, hotel, hotel name |
| ||||
| Posted By | For | Type | Date | |
| MapPoint Articles - MP2K Magazine | This thread | Refback | 06-27-2008 03:12 AM | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Find address within an X radius from an address | jparker | MapPoint 2006/2009 Discussion | 2 | 06-24-2008 10:26 AM |
| How to find City name for a location ??? | azorgnairelau | MapPoint 2006/2009 Discussion | 0 | 11-07-2007 11:01 AM |
| Find city/address from GPS position | GESwin | MapPoint 2006/2009 Discussion | 0 | 09-27-2004 04:56 AM |
| Given a city find zip codes? | amanuel | MapPoint 2006/2009 Discussion | 0 | 09-21-2002 01:32 PM |
| How to find nearest city? | Petr Brant | MapPoint 2006/2009 Discussion | 3 | 08-23-2002 02:49 PM |