Ejemplo n.º 1
0
func pqSelectString(query string, rules []mss.Rule, autoTypeFilter bool) string {
	if !autoTypeFilter {
		return query
	}
	filter := sql.FilterString(rules)
	return sql.WrapWhere(query, filter)
}
Ejemplo n.º 2
0
func pqSelectString(query, srid string, rules []mss.Rule, autoTypeFilter bool) string {
	/*
	   (select * from osm_landusages where type in ('forest', 'woods')) as landusages
	   ->
	   geometry from (select *, NULL as nullid from (select * from osm_landusages where type in ('forest', 'woods')) as landusages) as nullidq using unique nullid using srid=900913
	*/
	query = sqlComments.ReplaceAllString(query, " ")
	query = strings.Replace(query, "\n", " ", -1)
	query = strings.Replace(query, `"`, `\"`, -1)
	query = strings.Replace(query, `!bbox!`, `!BOX!`, -1)

	if autoTypeFilter {
		filter := sql.FilterString(rules)
		query = sql.WrapWhere(query, filter)
	}

	splitedQuery := strings.Split(strings.TrimRight(query, " "), " ")
	if len(splitedQuery) > 2 && strings.ToLower(splitedQuery[len(splitedQuery)-2]) == "as" {
		return "geometry from (select *, NULL as nullid from " + query + ") as nullidq using unique nullid using srid=" + srid
	}
	return "geometry from " + query
}