I am trying to filter a fusion table using the WHERE clause in order to display land areas below a certain size. I am not sure if it is a simple problem with the syntax but this filter will not work for me. Here is the code:
var layer = new google.maps.FusionTablesLayer({
query: {
select: 'Geometry',
from: 4310315,
where: 'rollingarea' < 400,
}
});
I have tried different variations such as where 'rollingarea < 40' & "'rollingarea' < 400" but cant get it to work.
Any help would be much appreciated
Looking at your table, the column name is "ROLLING AREA".
Try:
"'ROLLING AREA' < 400"
Related
So I have a set of data that needs to be displayed on the admin dashboard.
I decided to use laravel charting package ConsoleTvs Charts by Erik Campobadal.
I am using the package above to create charts directly from the database, the issue is, within my table (user's table for example) there are columns with NULL value.
How do I ignore this null values and represent only columns with real values on my chart?
`
$chart_print_media = Charts::database(User::all(), 'pie', 'highcharts')
->title('Print Media Campaign')
->dimensions(450, 300)
->groupBy('print_media',null);`
Thanks to Eric Campobadal, am just going to post the answer here for anyone that this might help in the future.
`
$users_print = User::all()->filter(function ($user) {
return $user->print_media !== null;
});
$chart_print_media = Charts::database($users_print, 'pie', 'highcharts')
->title('Print Media Campaign')
->dimensions(450, 300)
->groupBy('print_media');
`
I believe this is self-explanatory enough
I am writing with reference to an earlier question of mine, which also had to do with the use of Where clauses for Fusion Table Layer in Google Maps. Link to earlier question. I have noticed that if the Where clause in Styles section has more than one filtering conditions in it, it is ignored altogether. Google Map/Fusion Tables Layers then ends up applying that Style to ALL of the features contained in that Fusion table. You can remove a filtering condition from the Where clause to make it a single filter where clause, and it then works as expected so I am pretty sure that it doesn't like multiple filtering condition in the SAME where clause (or the way I am writing it).
Here is an example that illustrates this behavior:
layer = new google.maps.FusionTablesLayer({
map: map,
options: {
templateId: 2
},
heatmap: { enabled: false },
query: {
select: "geometry",
from: "1D6d93-0iT2zUCw8IvkbpDPYDx2-jA0ZAWXi07mQD",
},
styles: [{
//note multiple filters in the same Where clause.
where: "((SHIFT_ID != 1) AND (SHIFT_ID != 2))",
//you'd expect the following Style option applied to only those map features
//which met above criteria. However, they are applied to ALL map features.
polylineOptions: {
strokeOpacity: 0.70,
strokeColor: "#FFFFFF",
strokeWeight: "5" }
//if Where clause is reduced to just having one filter, it works fine.
//For example, either of the following two work fine by themselves.
//where: "SHIFT_ID != 1" --OR--
//where: "SHIFT_ID != 2" etc.
}]
});
Geocodezip was right; query was invalid.
This is what I have been able to determine re use of queries for Fusion Tables.
Can have multiple fields/filters in one where clause.
Can't use brackets "()" for Boolean logic.
Instead of !=, use NOT EQUAL TO
For NULL values, check equality with '' (empty string).
Field names are case sensitive.
https://developers.google.com/fusiontables/docs/v2/sql-reference
Using Alex Reisner's Ruby Geocoder, I have a model "Spot" which is geocoded using this gem
If I select the first spot into and object:
s = Spot.first
Then try to find all the spots within a 10 mile radius (let's say there should be 12 of them), then i would expect Spot.near(s,10) to return an active record object containing 12 spots. Instead it's just returning something like this every time:
Spot.near(s1,10)
=> {:select=>"spots.*, AS distance, CAST(DEGREES(ATAN2( RADIANS(spots.longitude - -6.88671972656243), RADIANS(spots.latitude - 55.1729431175342))) + 360 AS decimal) % 360 AS bearing", :conditions=>["spots.latitude BETWEEN 55.028211334423354 AND 55.31767490064505 AND spots.longitude BETWEEN -7.140145500612388 AND -6.633293952512472 AND <= ?", 10], :order=>"distance ASC"}
Basically it's returning some SQL but no results.
What's going wrong here? Even if i try something a lot wider, like:
Spot.near([40,0],10000)
I still basically get no results back...
EDIT
I am able to execute the query using this (not pretty) addition...
q = Spot.near(s1,10)
spots = Spot.select(q[:select]).where(q[:conditions]).order(q[:order])
I have written a SQL query, which extracts the lowest weekly price for a property stored in my database:
var rPropertyId = Request.QueryString["PropertyID"];
var cheapestrate = "SELECT TOP 1 * FROM RateInfo WHERE PropertyID=#0 ORDER BY RateWeekly ASC";
var qcheapestrate = db.QuerySingle (cheapestrate, rPropertyId);
I'm pretty confident that this statement is correct. The problem i have, is that not ALL propertys have pricing, so i only want to show this price if they do. I have created the below if statement, but it's telling me i'm missing an ; somewhere?
#if(qcheapestrate=!null){
Rates From qcheapestrate.rateweekly per week
}
So i'm trying to check if the query returns an entry. if it does, i want to show the lowest "rateweekly" value. Hopefully this all makes sense!
Try this...
#if(qcheapestrate!=null){
<text>Rates From</text>
#qcheapestrate.rateweekly
<text>per week</text>
}
I'm new to sqlalchemy and could use some help.
I'm trying to write a small application for which i have to dynamically change a select-statement. So I do s = select([files]), and then i add filters by s = s.where(files.c.createtime.between(val1, val2)).
This works great, but only with an AND-conjunction.
So, when I want to have all entries with createtime (between 1.1.2009 and 1.2.2009) OR createtime == 5.2.2009, I got the problem that i don't know how to achieve this with different filter-calls. Because of the programs logic it's not possible to use s= s.where(_or(files.c.createtime.between(val1, val2), files.c.createtime == DateTime('2009-02-01')))
Thanks in advance,
Christof
You can build or clauses dynamically from lists:
clauses = []
if cond1:
clauses.append(files.c.createtime.between(val1, val2))
if cond2:
clauses.append(files.c.createtime == DateTime('2009-02-01'))
if clauses:
s = s.where(or_(*clauses))
If you're willing to "cheat" by making use of the undocumented _whereclause attribute on Select objects, you can incrementally specify a series of OR terms by building a new query each time based on the previous query's where clause:
s = select([files]).where(literal(False)) # Start with an empty query.
s = select(s.froms).where(or_(s._whereclause,
files.c.createtime.between(val1, val2)))
s = select(s.froms).where(or_(s._whereclause,
files.c.createtime == datetime(2009, 2, 1)))
Building up a union is another option. This is a bit clunkier, but doesn't rely on undocumented attributes:
s = select([files]).where(literal(False)) # Start with an empty query.
s = s.select().union(
select([files]).where(files.c.createtime.between(val1, val2)))
s = s.select().union(
select([files]).where(files.c.createtime == datetime(2009, 2, 1)))