Exemple #1
0
		void getAddress(float lat, float lon,std::string &address){

			bool placeIDExist(false);
			mapValue.clear();

			pqxx::nontransaction nType((*ptrConn));

	        for (int i=0; i < 10; ++i){

	        	sql="select place_id,parent_place_id,rank_search from placex WHERE ST_DWithin(ST_SetSRID(ST_Point("+std::to_string(lon)+","+std::to_string(lat)+"),4326), "
	   		         "geometry, "+std::to_string(radius)+") and rank_search != 28 and rank_search >= 26 and (name is not null or housenumber is not null) and"
	   		         " class not in ('waterway','railway','tunnel','bridge') and indexed_status = 0 and "
	   		         "(ST_GeometryType(geometry) not in ('ST_Polygon','ST_MultiPolygon') "
	   		         "OR ST_DWithin(ST_SetSRID(ST_Point("+std::to_string(lon)+","+std::to_string(lat)+"),4326), centroid, "+std::to_string(radius)+")) "
	   		         "ORDER BY ST_distance(ST_SetSRID(ST_Point("+std::to_string(lon)+","+std::to_string(lat)+"),4326), geometry) ASC limit 1";

	        	//std::cout << sql << std::endl;

	        	resultSet = nType.exec(sql);

				if (!resultSet.empty()) {
					for (pqxx::result::const_iterator c = resultSet.begin(); c != resultSet.end(); ++c){
						//cout << '\t' << c[0].as(string()) << '\t' << c[1].as(string()) <<'\t' << c[2].as(string()) <<endl;
						place_id = c[0].as(std::string());
					}
					placeIDExist=true;
					break;
				}

				radius*=2;

	        }// end of for loop

	        if(placeIDExist){

	        	resultSet = nType.exec("select name,class,type from get_addressdata(" + place_id + ") where isaddress order by rank_address asc");

	            if (!resultSet.empty()) {
	            	for (pqxx::result::const_iterator c = resultSet.begin(); c != resultSet.end(); ++c){
	            		parseLocation( c[0].as(std::string()), c[1].as(std::string()), c[2].as(std::string()));
	            	}
	            }

	        }

	        printAddress(address);

		} // end of func getAddress
const bool tissuestack::database::LabelLookupDataProvider::persistLookupValues(const tissuestack::imaging::TissueStackLabelLookup * lookup)
{
	if (lookup == nullptr) return false;

	// request a new id
	const pqxx::result results =
		tissuestack::database::TissueStackPostgresConnector::instance()->executeNonTransactionalQuery(
			"SELECT NEXTVAL('atlas_info_id_seq'::regclass);");
	if (results.empty())
		return false;
	const unsigned long long int id =
		results[0][0].as<unsigned long long int>();

	const std::string sql =
		"INSERT INTO dataset_values_lookup (id, filename, content) VALUES("
			+ std::to_string(id)
			+ ",'"
			+ lookup->getLabelLookupId(true) + "','"
			+ lookup->getContentForSql() + "')";
	if (tissuestack::database::TissueStackPostgresConnector::instance()->executeTransaction({sql}) == 1)
	{
		const_cast<tissuestack::imaging::TissueStackLabelLookup *>(lookup)->setDataBaseInfo(id, nullptr);
		return true;
	}

	return false;
}