MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Find address given hotel name and city

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 ...


Go Back   MapPoint Forums > Map Forums > MapPoint Web Service and Virtual Earth

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack (1) Thread Tools Display Modes
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 06-24-2008
Junior Member
White Belt
 
Join Date: Jun 2008
Posts: 4
Question Find address given hotel name and city

Hello,

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 07-11-2008
Junior Member
White Belt
 
Join Date: Jun 2008
Posts: 4
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 getAddresses(final String addressString) {
List matchedAddressesList = new ArrayList();
/************************************************** *********************
* 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;
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 07-11-2008
Junior Member
White Belt
 
Join Date: Jun 2008
Posts: 4
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 findLandmarkAddress(
final String addressString,
final String filter,
final String displayName) {
List matchedAddressesList = new ArrayList();
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;
}

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
address, city, find, hotel, hotel name


LinkBacks (?)
LinkBack to this Thread: http://www.mapforums.com/find-address-given-hotel-name-city-7930.html

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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

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


All times are GMT -5. The time now is 12:49 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55