Sce logo

Purpose:

Allow view/download of filtered records from the Monuments application.

Method:

The primary method of filtering is by adding Search Terms, an optional Sort Term, and a Format Specification to the URL.

For example:

/monuments.xml?q[horz_order_cont]=fir&q[usgs_quad_cont]=rich
Return all records where the horz_order contains 'fir' and the usgs_quad contains 'rich', in xml format.

OR

/monuments.json?q[vert_order_or_horz_order_cont]=thir&q[s]=pid
Return all records where the vert_order or horz_order contain 'thir', sorted by PID, in json format.

Search Terms:

A search term has the following structure:

q[horz_order_cont]=fir
q
Constant designates a search term in the querystring.
[horz_order
Variable field name to be searched
_cont]
Variable Ransack predicate(listed below)
=
Constant designates the target term of the search
fir
Variable target term

or:

q[vert_order_or_horz_order_cont]=thir
q
Constant designates a search term in the querystring.
[vert_order_or_horz_order
Variable field names to be searched
_cont]
Variable Ransack predicate (listed below)
=
Constant designates the target term of the search
thir
Variable target term

Sort Term:

A sort term has the following structure:

q[s]=pid
q[s]
Constant designates the sort term in the querystring.
\=
Constant designates the target term of the sort
pid
Variable field name by which the results are to be sorted

Formats:

?format=xml OR /monuments.xml?{query string}
Three formats are supported: xls, xml, and json. Xls format triggers download of an Excel-format file with the search results.

Predicates:

Ransack predicates are used to determine what information to match. For instance, an "vert_order_cont" predicate will return all records where an attribute called "vert_order" contains a value using a wildcard query: The SQL equivalent of [vert_order_cont]=firs is

SELECT "monuments".* FROM "monuments" WHERE("monuments"."vert_order" LIKE '%firs%')

You can also combine predicates for OR queries:

The SQL equivalent of [vert_or_horz_order_cont]=thir is

SELECT "monuments".* FROM "monuments" WHERE("monuments"."vert_order" LIKE '%thir%' OR "monuments"."horz_order" LIKE '%thir%')

Below is a table of predicates and their opposites.

Predicate Meaning Opposite
eq The eq predicate returns all records where a field is exactly equal to a given value: not_eq
matches The matches predicate returns all records where a field is like a given value. *Note: If you want to do wildcard matching, you may be looking for the cont/not_cont predicates instead. does_not_match
lt (less than) The lt predicate returns all records where a field is less than a given value gteq (greater than or equal to)
in The in predicate returns all records where a field is within a specified list not_in
cont The cont predicate returns all records where a field contains a given value not_cont
cont_any (contains any) The cont_any predicate returns all records where a field contains any of given values not_cont_any
start (starts with) The start predicate returns all records where a field begins with a given value not_start
end (ends with) The end predicate returns all records where a field ends with a given value not_end
true The true predicate returns all records where a field is true. The "1" indicates that to Ransack that you indeed want to check the truthiness of this field. The other truthy values are 'true', 'TRUE', 't' or 'T'. false
present The present predicate returns all records where a field is present (not null and not a blank string). blank
null The null predicate returns all records where a field is null not_null

Fields and Descriptions:

id
old_monument_id
latitude
longitude
station
pid
state
county
usgs_quad
set_by
dtset
marktype
stamping
who
whendone
history
horz_datum
horz_order
ynadjusted
position_lat_deg
position_lat_min
position_lat_sec
position_lat_dir
position_long_deg
position_long_min
position_long_sec
position_long_dir
positiontype
geoid_height
geoid_by
geoid_explanation
spc_zone
spc_northing
spc_easting
spc_scale_factor
spc_sign
spc_convergence_deg
spc_convergence_min
spc_convergence_sec
spc_foottype
spc_units
stability
spcmethod
spc_agency
spc_dtby
height_meters
height_feet
height_source
epochdate
laplacecorr_correction
laplacecorr_source
ellip_height
ellip_x
ellip_y
ellip_z
modeled_grav_gravity
modeled_grav_by
vert_datum
vert_order
vert_order_class
elevation_method
elevation_agency
elevation_dtby
description
dtrecovery
recovery_agency
recoverycondition
gps_suitability
originaltext
g83minus27_lat_sign
g83minus27_lat_shift
g83minus27_long_sign
g83minus27_long_shift
g83minus27how
g88minus29_height_sign
g88minus29_height_shift
g88minus29how
dyminus88_height_sign
dyminus88_height_shift
dyminus88how
displaye
displayn
indicator_spc_ft
ynactive
dtupdated
is_cadastral