Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions templates/android/library/src/main/java/io/package/Query.kt.twig
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,122 @@ class Query(
*/
fun and(queries: List<String>) = Query("and", null, queries.map { it.fromJson<Query>() }).toJson()

/**
* Filter resources where attribute is at a specific distance from the given coordinates.
*
* @param attribute The attribute to filter on.
* @param values The coordinate values.
* @param distance The distance value.
* @param meters Whether the distance is in meters.
* @returns The query string.
*/
fun distanceEqual(attribute: String, values: List<Any>, distance: Number, meters: Boolean = false) = Query("distanceEqual", attribute, listOf(values, distance, meters)).toJson()

/**
* Filter resources where attribute is not at a specific distance from the given coordinates.
*
* @param attribute The attribute to filter on.
* @param values The coordinate values.
* @param distance The distance value.
* @param meters Whether the distance is in meters.
* @returns The query string.
*/
fun distanceNotEqual(attribute: String, values: List<Any>, distance: Number, meters: Boolean = false) = Query("distanceNotEqual", attribute, listOf(values, distance, meters)).toJson()

/**
* Filter resources where attribute is at a distance greater than the specified value from the given coordinates.
*
* @param attribute The attribute to filter on.
* @param values The coordinate values.
* @param distance The distance value.
* @param meters Whether the distance is in meters.
* @returns The query string.
*/
fun distanceGreaterThan(attribute: String, values: List<Any>, distance: Number, meters: Boolean = false) = Query("distanceGreaterThan", attribute, listOf(values, distance, meters)).toJson()

/**
* Filter resources where attribute is at a distance less than the specified value from the given coordinates.
*
* @param attribute The attribute to filter on.
* @param values The coordinate values.
* @param distance The distance value.
* @param meters Whether the distance is in meters.
* @returns The query string.
*/
fun distanceLessThan(attribute: String, values: List<Any>, distance: Number, meters: Boolean = false) = Query("distanceLessThan", attribute, listOf(values, distance, meters)).toJson()

/**
* Filter resources where attribute intersects with the given geometry.
*
* @param attribute The attribute to filter on.
* @param values The coordinate values.
* @returns The query string.
*/
fun intersects(attribute: String, values: List<Any>) = Query("intersects", attribute, values).toJson()

/**
* Filter resources where attribute does not intersect with the given geometry.
*
* @param attribute The attribute to filter on.
* @param values The coordinate values.
* @returns The query string.
*/
fun notIntersects(attribute: String, values: List<Any>) = Query("notIntersects", attribute, values).toJson()

/**
* Filter resources where attribute crosses the given geometry.
*
* @param attribute The attribute to filter on.
* @param values The coordinate values.
* @returns The query string.
*/
fun crosses(attribute: String, values: List<Any>) = Query("crosses", attribute, values).toJson()

/**
* Filter resources where attribute does not cross the given geometry.
*
* @param attribute The attribute to filter on.
* @param values The coordinate values.
* @returns The query string.
*/
fun notCrosses(attribute: String, values: List<Any>) = Query("notCrosses", attribute, values).toJson()

/**
* Filter resources where attribute overlaps with the given geometry.
*
* @param attribute The attribute to filter on.
* @param values The coordinate values.
* @returns The query string.
*/
fun overlaps(attribute: String, values: List<Any>) = Query("overlaps", attribute, values).toJson()

/**
* Filter resources where attribute does not overlap with the given geometry.
*
* @param attribute The attribute to filter on.
* @param values The coordinate values.
* @returns The query string.
*/
fun notOverlaps(attribute: String, values: List<Any>) = Query("notOverlaps", attribute, values).toJson()

/**
* Filter resources where attribute touches the given geometry.
*
* @param attribute The attribute to filter on.
* @param values The coordinate values.
* @returns The query string.
*/
fun touches(attribute: String, values: List<Any>) = Query("touches", attribute, values).toJson()

/**
* Filter resources where attribute does not touch the given geometry.
*
* @param attribute The attribute to filter on.
* @param values The coordinate values.
* @returns The query string.
*/
fun notTouches(attribute: String, values: List<Any>) = Query("notTouches", attribute, values).toJson()

/**
* Parse the value to a list of values.
*
Expand Down
48 changes: 48 additions & 0 deletions templates/dart/lib/query.dart.twig
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,52 @@ class Query {
/// docs for more information.
static String offset(int offset) =>
Query._('offset', null, offset).toString();

/// Filter resources where [attribute] is at a specific distance from the given coordinates.
static String distanceEqual(String attribute, List<dynamic> values, double distance, [bool meters = false]) =>
Query._('distanceEqual', attribute, [values, distance, meters]).toString();

/// Filter resources where [attribute] is not at a specific distance from the given coordinates.
static String distanceNotEqual(String attribute, List<dynamic> values, double distance, [bool meters = false]) =>
Query._('distanceNotEqual', attribute, [values, distance, meters]).toString();

/// Filter resources where [attribute] is at a distance greater than the specified value from the given coordinates.
static String distanceGreaterThan(String attribute, List<dynamic> values, double distance, [bool meters = false]) =>
Query._('distanceGreaterThan', attribute, [values, distance, meters]).toString();

/// Filter resources where [attribute] is at a distance less than the specified value from the given coordinates.
static String distanceLessThan(String attribute, List<dynamic> values, double distance, [bool meters = false]) =>
Query._('distanceLessThan', attribute, [values, distance, meters]).toString();

/// Filter resources where [attribute] intersects with the given geometry.
static String intersects(String attribute, List<dynamic> values) =>
Query._('intersects', attribute, values).toString();

/// Filter resources where [attribute] does not intersect with the given geometry.
static String notIntersects(String attribute, List<dynamic> values) =>
Query._('notIntersects', attribute, values).toString();

/// Filter resources where [attribute] crosses the given geometry.
static String crosses(String attribute, List<dynamic> values) =>
Query._('crosses', attribute, values).toString();

/// Filter resources where [attribute] does not cross the given geometry.
static String notCrosses(String attribute, List<dynamic> values) =>
Query._('notCrosses', attribute, values).toString();

/// Filter resources where [attribute] overlaps with the given geometry.
static String overlaps(String attribute, List<dynamic> values) =>
Query._('overlaps', attribute, values).toString();

/// Filter resources where [attribute] does not overlap with the given geometry.
static String notOverlaps(String attribute, List<dynamic> values) =>
Query._('notOverlaps', attribute, values).toString();

/// Filter resources where [attribute] touches the given geometry.
static String touches(String attribute, List<dynamic> values) =>
Query._('touches', attribute, values).toString();

/// Filter resources where [attribute] does not touch the given geometry.
static String notTouches(String attribute, List<dynamic> values) =>
Query._('notTouches', attribute, values).toString();
}
128 changes: 128 additions & 0 deletions templates/deno/src/query.ts.twig
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,132 @@ export class Query {

static and = (queries: string[]) =>
new Query("and", undefined, queries.map((query) => JSON.parse(query))).toString();

/**
* Filter resources where attribute is at a specific distance from the given coordinates.
*
* @param {string} attribute
* @param {any[]} values
* @param {number} distance
* @param {boolean} meters
* @returns {string}
*/
static distanceEqual = (attribute: string, values: any[], distance: number, meters: boolean = false): string =>
new Query("distanceEqual", attribute, [values, distance, meters] as QueryTypesList).toString();

/**
* Filter resources where attribute is not at a specific distance from the given coordinates.
*
* @param {string} attribute
* @param {any[]} values
* @param {number} distance
* @param {boolean} meters
* @returns {string}
*/
static distanceNotEqual = (attribute: string, values: any[], distance: number, meters: boolean = false): string =>
new Query("distanceNotEqual", attribute, [values, distance, meters] as QueryTypesList).toString();

/**
* Filter resources where attribute is at a distance greater than the specified value from the given coordinates.
*
* @param {string} attribute
* @param {any[]} values
* @param {number} distance
* @param {boolean} meters
* @returns {string}
*/
static distanceGreaterThan = (attribute: string, values: any[], distance: number, meters: boolean = false): string =>
new Query("distanceGreaterThan", attribute, [values, distance, meters] as QueryTypesList).toString();

/**
* Filter resources where attribute is at a distance less than the specified value from the given coordinates.
*
* @param {string} attribute
* @param {any[]} values
* @param {number} distance
* @param {boolean} meters
* @returns {string}
*/
static distanceLessThan = (attribute: string, values: any[], distance: number, meters: boolean = false): string =>
new Query("distanceLessThan", attribute, [values, distance, meters] as QueryTypesList).toString();

/**
* Filter resources where attribute intersects with the given geometry.
*
* @param {string} attribute
* @param {any[]} values
* @returns {string}
*/
static intersects = (attribute: string, values: any[]): string =>
new Query("intersects", attribute, values).toString();

/**
* Filter resources where attribute does not intersect with the given geometry.
*
* @param {string} attribute
* @param {any[]} values
* @returns {string}
*/
static notIntersects = (attribute: string, values: any[]): string =>
new Query("notIntersects", attribute, values).toString();

/**
* Filter resources where attribute crosses the given geometry.
*
* @param {string} attribute
* @param {any[]} values
* @returns {string}
*/
static crosses = (attribute: string, values: any[]): string =>
new Query("crosses", attribute, values).toString();

/**
* Filter resources where attribute does not cross the given geometry.
*
* @param {string} attribute
* @param {any[]} values
* @returns {string}
*/
static notCrosses = (attribute: string, values: any[]): string =>
new Query("notCrosses", attribute, values).toString();

/**
* Filter resources where attribute overlaps with the given geometry.
*
* @param {string} attribute
* @param {any[]} values
* @returns {string}
*/
static overlaps = (attribute: string, values: any[]): string =>
new Query("overlaps", attribute, values).toString();

/**
* Filter resources where attribute does not overlap with the given geometry.
*
* @param {string} attribute
* @param {any[]} values
* @returns {string}
*/
static notOverlaps = (attribute: string, values: any[]): string =>
new Query("notOverlaps", attribute, values).toString();

/**
* Filter resources where attribute touches the given geometry.
*
* @param {string} attribute
* @param {any[]} values
* @returns {string}
*/
static touches = (attribute: string, values: any[]): string =>
new Query("touches", attribute, values).toString();

/**
* Filter resources where attribute does not touch the given geometry.
*
* @param {string} attribute
* @param {any[]} values
* @returns {string}
*/
static notTouches = (attribute: string, values: any[]): string =>
new Query("notTouches", attribute, values).toString();
}
60 changes: 60 additions & 0 deletions templates/dotnet/Package/Query.cs.twig
Original file line number Diff line number Diff line change
Expand Up @@ -201,5 +201,65 @@ namespace {{ spec.title | caseUcfirst }}
public static string And(List<string> queries) {
return new Query("and", null, queries.Select(q => JsonSerializer.Deserialize<Query>(q, Client.DeserializerOptions)).ToList()).ToString();
}

public static string DistanceEqual(string attribute, List<object> values, double distance, bool meters = false)
{
return new Query("distanceEqual", attribute, new List<object> { values, distance, meters }).ToString();
}

public static string DistanceNotEqual(string attribute, List<object> values, double distance, bool meters = false)
{
return new Query("distanceNotEqual", attribute, new List<object> { values, distance, meters }).ToString();
}

public static string DistanceGreaterThan(string attribute, List<object> values, double distance, bool meters = false)
{
return new Query("distanceGreaterThan", attribute, new List<object> { values, distance, meters }).ToString();
}

public static string DistanceLessThan(string attribute, List<object> values, double distance, bool meters = false)
{
return new Query("distanceLessThan", attribute, new List<object> { values, distance, meters }).ToString();
}

public static string Intersects(string attribute, List<object> values)
{
return new Query("intersects", attribute, values).ToString();
}

public static string NotIntersects(string attribute, List<object> values)
{
return new Query("notIntersects", attribute, values).ToString();
}

public static string Crosses(string attribute, List<object> values)
{
return new Query("crosses", attribute, values).ToString();
}

public static string NotCrosses(string attribute, List<object> values)
{
return new Query("notCrosses", attribute, values).ToString();
}

public static string Overlaps(string attribute, List<object> values)
{
return new Query("overlaps", attribute, values).ToString();
}

public static string NotOverlaps(string attribute, List<object> values)
{
return new Query("notOverlaps", attribute, values).ToString();
}

public static string Touches(string attribute, List<object> values)
{
return new Query("touches", attribute, values).ToString();
}

public static string NotTouches(string attribute, List<object> values)
{
return new Query("notTouches", attribute, values).ToString();
}
}
}
Loading
Loading