Point p = fac.createPoint(c);
return p;
}
public List<SimpleFeature> geocode(String address) throws IOException,XmlRpcException {
GeometryFactory fac = new GeometryFactory();
XmlRpcClient geocoder = getGeoCoderClient(username, password);
Vector params = new Vector();
params.addElement(address);
// this method returns a string
Vector<Hashtable<String,Object>> vec = (Vector<Hashtable<String,Object>>)geocoder.execute("geocode", params); //$NON-NLS-1$
System.out.println("vec"+vec); //$NON-NLS-1$
List<String> keys = keys( vec );
SimpleFeatureType ADDRESS = createAddressType( keys );
List<SimpleFeature> places = new ArrayList<SimpleFeature>( vec.size() );
int count=1;
for( Hashtable table : vec ){
double lat = Double.NaN, lon = Double.NaN;
Object values[] = new Object[keys.size()-1];
int index = 0;
for( String key : keys ){
if( !table.containsKey( key )){
System.out.println("missed key - "+key ); //$NON-NLS-1$
continue;
}
else {
if( "lat".equals( key ) ){ //$NON-NLS-1$
lat = ((Number)table.get("lat")).doubleValue(); //$NON-NLS-1$
continue;
}
else if( "long".equals( key ) ){ //$NON-NLS-1$
lon = ((Number)table.get("long")).doubleValue(); //$NON-NLS-1$
continue;
}
values[index] = table.get( key );
}
index++;
}
if( Double.isNaN( lat ) || Double.isNaN( lon )){
System.out.println("missed location - " ); //$NON-NLS-1$
}
else {
values[index] = fac.createPoint( new Coordinate(lon, lat) );
}
try{
SimpleFeature f = SimpleFeatureBuilder.build(ADDRESS, values, fid( count++, table ) );
places.add( f );
} catch(Exception e){