@SuppressWarnings({ "rawtypes", "unchecked" })
public static HashMap writeResolvedLocationToHash(ResolvedLocation resolvedLocation){
HashMap loc = new HashMap();
int charIndex = resolvedLocation.getLocation().getPosition();
GeoName place = resolvedLocation.getGeoname();
loc.put("confidence", resolvedLocation.getConfidence()); // low is good
loc.put("id",place.getGeonameID());
loc.put("name",place.getName());
String primaryCountryCodeAlpha2 = "";
if(place.getPrimaryCountryCode()!=CountryCode.NULL){
primaryCountryCodeAlpha2 = place.getPrimaryCountryCode().toString();
}
String admin1Code = "";
if(place.getAdmin1Code() !=null){
admin1Code = place.getAdmin1Code();
}
String featureCode = place.getFeatureCode().toString();
loc.put("featureClass", place.getFeatureClass().toString());
loc.put("featureCode", featureCode);
loc.put("population", place.getPopulation());
loc.put("stateCode", admin1Code);
loc.put("countryCode",primaryCountryCodeAlpha2);
loc.put("lat",place.getLatitude());
loc.put("lon",place.getLongitude());
HashMap sourceInfo = new HashMap();
sourceInfo.put("string",resolvedLocation.getLocation().getText());
sourceInfo.put("charIndex",charIndex);
if(resolvedLocation.getLocation() instanceof SentenceLocationOccurrence){
sourceInfo.put("storySentencesId", ((SentenceLocationOccurrence) resolvedLocation.getLocation()).storySentenceId);