Hello,

I've got a view showing a company directory.

For each company I have an addressfiield and a geofield set to geocode the addressfield using Google Geocoder.

Then I created a proximity exposed filter in my view for the geofield, but no matter which settings I use. I always get this error:

SQLSTATE[42000]: Syntax error or access violation: 1582 Incorrect parameter count in the call to native function 'RADIANS'

Thanks for any help you can offer,

Comments

Brandonian’s picture

@joelinvisible, can you provide an export of your view?

Off the cuff, I suspect that it's an issue with null values in your geocoded data, but I don't have anything to back that up yet. Do you have any blank Address fields with your data?

joelinvisible’s picture

Hi @Brandonian, thanks for your help, here's my views export:


$view = new view;
$view->name = 'member_directory';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Member Directory';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Member Directory';
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['distinct'] = TRUE;
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'better_exposed_filters';
$handler->display->display_options['exposed_form']['options']['submit_button'] = 'Search member directory';
$handler->display->display_options['exposed_form']['options']['autosubmit'] = 1;
$handler->display->display_options['exposed_form']['options']['autosubmit_hide'] = 0;
$handler->display->display_options['exposed_form']['options']['bef'] = array(
  'field_member_category_value' => array(
    'bef_format' => 'bef',
    'more_options' => array(
      'bef_select_all_none' => 0,
      'bef_collapsible' => 0,
      'bef_filter_description' => '',
    ),
  ),
);
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['pager']['options']['items_per_page'] = '0';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['style_plugin'] = 'grid';
$handler->display->display_options['style_options']['columns'] = '1';
$handler->display->display_options['style_options']['fill_single_line'] = 1;
$handler->display->display_options['row_plugin'] = 'fields';
$handler->display->display_options['row_options']['separator'] = '<br/>';
$handler->display->display_options['row_options']['hide_empty'] = 1;
$handler->display->display_options['row_options']['default_field_elements'] = 1;
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['exclude'] = TRUE;
$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['title']['alter']['external'] = 0;
$handler->display->display_options['fields']['title']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['title']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['title']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
$handler->display->display_options['fields']['title']['alter']['more_link'] = 0;
$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
$handler->display->display_options['fields']['title']['alter']['html'] = 0;
$handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['title']['element_default_classes'] = 1;
$handler->display->display_options['fields']['title']['hide_empty'] = 0;
$handler->display->display_options['fields']['title']['empty_zero'] = 0;
$handler->display->display_options['fields']['title']['hide_alter_empty'] = 1;
$handler->display->display_options['fields']['title']['link_to_node'] = 0;

/* Field: Content: Address */
$handler->display->display_options['fields']['field_full_address']['id'] = 'field_full_address';
$handler->display->display_options['fields']['field_full_address']['table'] = 'field_data_field_full_address';
$handler->display->display_options['fields']['field_full_address']['field'] = 'field_full_address';
$handler->display->display_options['fields']['field_full_address']['alter']['alter_text'] = 1;
$handler->display->display_options['fields']['field_full_address']['alter']['text'] = '[field_full_address] <hr/>';
$handler->display->display_options['fields']['field_full_address']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['field_full_address']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['field_full_address']['alter']['external'] = 0;
$handler->display->display_options['fields']['field_full_address']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['field_full_address']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['field_full_address']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['field_full_address']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['field_full_address']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['field_full_address']['alter']['more_link'] = 0;
$handler->display->display_options['fields']['field_full_address']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['field_full_address']['alter']['trim'] = 0;
$handler->display->display_options['fields']['field_full_address']['alter']['html'] = 0;
$handler->display->display_options['fields']['field_full_address']['element_label_type'] = 'strong';
$handler->display->display_options['fields']['field_full_address']['element_label_colon'] = 1;
$handler->display->display_options['fields']['field_full_address']['element_default_classes'] = 1;
$handler->display->display_options['fields']['field_full_address']['hide_empty'] = 0;
$handler->display->display_options['fields']['field_full_address']['empty_zero'] = 0;
$handler->display->display_options['fields']['field_full_address']['hide_alter_empty'] = 1;
$handler->display->display_options['fields']['field_full_address']['click_sort_column'] = 'country';
$handler->display->display_options['fields']['field_full_address']['settings'] = array(
  'use_widget_handlers' => 1,
  'format_handlers' => array(
    'address' => 'address',
  ),
);
$handler->display->display_options['fields']['field_full_address']['field_api_classes'] = 0;
/* Field: Content: location Search */
$handler->display->display_options['fields']['field_location_search']['id'] = 'field_location_search';
$handler->display->display_options['fields']['field_location_search']['table'] = 'field_data_field_location_search';
$handler->display->display_options['fields']['field_location_search']['field'] = 'field_location_search';
$handler->display->display_options['fields']['field_location_search']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['field_location_search']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['field_location_search']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['field_location_search']['alter']['external'] = 0;
$handler->display->display_options['fields']['field_location_search']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['field_location_search']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['field_location_search']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['field_location_search']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['field_location_search']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['field_location_search']['alter']['more_link'] = 0;
$handler->display->display_options['fields']['field_location_search']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['field_location_search']['alter']['trim'] = 0;
$handler->display->display_options['fields']['field_location_search']['alter']['html'] = 0;
$handler->display->display_options['fields']['field_location_search']['element_label_colon'] = 1;
$handler->display->display_options['fields']['field_location_search']['element_default_classes'] = 1;
$handler->display->display_options['fields']['field_location_search']['hide_empty'] = 0;
$handler->display->display_options['fields']['field_location_search']['empty_zero'] = 0;
$handler->display->display_options['fields']['field_location_search']['hide_alter_empty'] = 1;
$handler->display->display_options['fields']['field_location_search']['click_sort_column'] = 'wkt';
$handler->display->display_options['fields']['field_location_search']['type'] = 'geofield_latlon';
$handler->display->display_options['fields']['field_location_search']['settings'] = array(
  'data' => 'full',
  'format' => 'decimal_degrees',
  'labels' => 1,
);
$handler->display->display_options['fields']['field_location_search']['field_api_classes'] = 0;
/* Sort criterion: Content: Title */
$handler->display->display_options['sorts']['title']['id'] = 'title';
$handler->display->display_options['sorts']['title']['table'] = 'node';
$handler->display->display_options['sorts']['title']['field'] = 'title';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;

/* Filter criterion: Content: Location Search - proximity */
$handler->display->display_options['filters']['field_geofield_distance']['id'] = 'field_geofield_distance';
$handler->display->display_options['filters']['field_geofield_distance']['table'] = 'field_data_field_location_search';
$handler->display->display_options['filters']['field_geofield_distance']['field'] = 'field_geofield_distance';
$handler->display->display_options['filters']['field_geofield_distance']['value'] = array(
  'distance' => '100',
  'distance2' => 200,
  'unit' => '6371',
  'origin' => '',
);
$handler->display->display_options['filters']['field_geofield_distance']['exposed'] = TRUE;
$handler->display->display_options['filters']['field_geofield_distance']['expose']['operator_id'] = 'field_geofield_distance_op';
$handler->display->display_options['filters']['field_geofield_distance']['expose']['label'] = 'Location Search - proximity';
$handler->display->display_options['filters']['field_geofield_distance']['expose']['operator'] = 'field_geofield_distance_op';
$handler->display->display_options['filters']['field_geofield_distance']['expose']['identifier'] = 'field_geofield_distance';
$handler->display->display_options['filters']['field_geofield_distance']['expose']['multiple'] = FALSE;
$handler->display->display_options['filters']['field_geofield_distance']['source'] = 'geocode';


/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'member-directory';
Brandonian’s picture

Status: Active » Fixed

This should be fixed with the commit I did today for #1614344: Make input optional in proximity searches - fix for Notice

http://drupalcode.org/project/geofield.git/commit/8e1ff0e

If this isn't the case, please reopen.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

johnlutz’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new720 bytes

Looks like this problem resurfaced after you revamped your filter handler code in late 2012. Uploaded a patch which solves the problem for me. Issue was that on initial display there were empty latitude and longitude values in $options array.

jlporter’s picture

#5 - agreed, have same issue. Patch did not apply cleanly but I replicated your fix against our repo and it fixed the issue.

gianfrasoft’s picture

I already have the same problem.

Here is my view:

$view = new view();
$view->name = 'geo_test';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Geo test';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Geo test';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['use_more_text'] = 'altro';
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['exposed_form']['options']['submit_button'] = 'Applica';
$handler->display->display_options['exposed_form']['options']['reset_button_label'] = 'Ripristina';
$handler->display->display_options['exposed_form']['options']['exposed_sorts_label'] = 'Ordina per';
$handler->display->display_options['exposed_form']['options']['sort_desc_label'] = 'Disc';
$handler->display->display_options['pager']['type'] = 'none';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Comportamento se non ci sono risultati: Globale: Area di testo */
$handler->display->display_options['empty']['area']['id'] = 'area';
$handler->display->display_options['empty']['area']['table'] = 'views';
$handler->display->display_options['empty']['area']['field'] = 'area';
$handler->display->display_options['empty']['area']['empty'] = TRUE;
$handler->display->display_options['empty']['area']['content'] = 'Nessun risultato trovato.';
$handler->display->display_options['empty']['area']['format'] = 'full_html';
/* Campo: Contenuto: Geofield - proximity */
$handler->display->display_options['fields']['field_geofield_distance']['id'] = 'field_geofield_distance';
$handler->display->display_options['fields']['field_geofield_distance']['table'] = 'field_data_field_geocode';
$handler->display->display_options['fields']['field_geofield_distance']['field'] = 'field_geofield_distance';
$handler->display->display_options['fields']['field_geofield_distance']['precision'] = '0';
$handler->display->display_options['fields']['field_geofield_distance']['geofield_proximity_manual'] = array(
  'lat' => '',
  'lon' => '',
);
$handler->display->display_options['fields']['field_geofield_distance']['geofield_proximity_entity_url_field'] = 'field_geocode';
$handler->display->display_options['fields']['field_geofield_distance']['geofield_proximity_current_user_field'] = 'field_geocode';
$handler->display->display_options['fields']['field_geofield_distance']['radius_of_earth'] = '6371';
/* Campo: Contenuto: Titolo */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
/* Criterio di ordinamento: Contenuto: Geofield - proximity */
$handler->display->display_options['sorts']['field_geofield_distance']['id'] = 'field_geofield_distance';
$handler->display->display_options['sorts']['field_geofield_distance']['table'] = 'field_data_field_geocode';
$handler->display->display_options['sorts']['field_geofield_distance']['field'] = 'field_geofield_distance';
$handler->display->display_options['sorts']['field_geofield_distance']['source'] = 'exposed_geofield_filter';
$handler->display->display_options['sorts']['field_geofield_distance']['geofield_proximity_manual'] = array(
  'lat' => '',
  'lon' => '',
);
$handler->display->display_options['sorts']['field_geofield_distance']['geofield_proximity_entity_url_field'] = 'field_geocode';
$handler->display->display_options['sorts']['field_geofield_distance']['geofield_proximity_current_user_field'] = 'field_geocode';
/* Criterio del filtro: Contenuto: Pubblicato */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Criterio del filtro: Contenuto: Tipo */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
  'clienti' => 'clienti',
);
/* Criterio del filtro: Contenuto: Geofield - proximity */
$handler->display->display_options['filters']['field_geofield_distance']['id'] = 'field_geofield_distance';
$handler->display->display_options['filters']['field_geofield_distance']['table'] = 'field_data_field_geocode';
$handler->display->display_options['filters']['field_geofield_distance']['field'] = 'field_geofield_distance';
$handler->display->display_options['filters']['field_geofield_distance']['operator'] = '<=';
$handler->display->display_options['filters']['field_geofield_distance']['value'] = array(
  'distance' => '300',
  'distance2' => 200,
  'unit' => '6371',
  'origin' => '',
);
$handler->display->display_options['filters']['field_geofield_distance']['exposed'] = TRUE;
$handler->display->display_options['filters']['field_geofield_distance']['expose']['operator_id'] = 'field_geofield_distance_op';
$handler->display->display_options['filters']['field_geofield_distance']['expose']['label'] = 'Geofield - proximity';
$handler->display->display_options['filters']['field_geofield_distance']['expose']['operator'] = 'field_geofield_distance_op';
$handler->display->display_options['filters']['field_geofield_distance']['expose']['identifier'] = 'field_geofield_distance';
$handler->display->display_options['filters']['field_geofield_distance']['expose']['required'] = TRUE;
$handler->display->display_options['filters']['field_geofield_distance']['expose']['remember_roles'] = array(
  2 => '2',
  1 => 0,
  3 => 0,
  4 => 0,
);
$handler->display->display_options['filters']['field_geofield_distance']['source'] = 'geocoder';
$handler->display->display_options['filters']['field_geofield_distance']['geofield_proximity_entity_url_field'] = 'field_geocode';
$handler->display->display_options['filters']['field_geofield_distance']['geofield_proximity_current_user_field'] = 'field_geocode';

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['defaults']['hide_admin_links'] = FALSE;
$handler->display->display_options['path'] = 'geo-test';
$translatables['geo_test'] = array(
  t('Master'),
  t('Geo test'),
  t('altro'),
  t('Applica'),
  t('Ripristina'),
  t('Ordina per'),
  t('Asc'),
  t('Disc'),
  t('Nessun risultato trovato.'),
  t('Geofield - proximity'),
  t('.'),
  t(','),
  t('Titolo'),
  t('Page'),
);

gianfrasoft’s picture

Ok, I solved! Maybe my solution should help someone else... That is:

In my view I added the Geocode-proximity field to fields list. So I set the "Source of Origin Point" to "Manually enter Point" as was specified in a couple of articles online: Wrong!

Solution:
"Source of Origin Point" have to be set to "Geocoded Location"!!!

P.S. I'm using latest module version, the one published on GIT.

callums’s picture

I got stuck with this error for a couple of hours but finally figured out my issue.

It seems the "Geocoding Service" drop down for the proximity exposed filter reverts to "KML" after the view is saved.

When the view is saved I need to make sure that "Google Geocoder" is selected instead of "KML".

mgifford’s picture

Would be great if there were some warning or alert rather than a strange error message.

@gianfrasoft & @sleepyscene have different solutions.

Is it now safe to use this with the latest stable release (7.x-2.0)?

I do hope that there's no need to keep using the git version.

stopshinal’s picture

I have both a map and list view. I'm trying to apply a 'sort' so the nearest location is show first in the list. I'm not sure I can include a 'distance' field - otherwise I could sort on that. Does anyone have any ideas on how to implement a sort like this?

bneil’s picture

Category: Support request » Bug report
Issue summary: View changes
Status: Needs review » Needs work

I received this error after setting my "Source of Origin Point" to "Manually enter Point" and did not provide a default value. Once I added a default value, the error was gone.

I agree with mgifford, it would be nice to have some sort of notice instead of the error. Setting to needs work re: comment 6.

Stopshinal - There is a field-proximity sort handler available that you can use in conjunction with the exposed filter.

bneil’s picture

Title: Views Exposed Filter for Proximity » Views Exposed Filter for Proximity SQL error
bneil’s picture

StatusFileSize
new721 bytes

Here's a rerolled patch that applies cleanly. However, it I still receive the error on view edit with the patch applied.

cmonnow’s picture

I have to sleep now so and I just lost the page once so sorry I have to be quick.

In geofield/views/proximityplugins/geofieldProximityManual.inc the function getSourceValue($views_plugin) is, on face value at least, meant to check whether a submitted value or otherwise the manual defaults have been set or not in $views_plugin->value and if not, simply return 0 (set previously in the page, $views_plugin->options['geofield_proximity_manual']['lon']).

The problem is (isset($views_plugin->value) is always true so if the values in $views_plugin->value['origin']['lat'] or $views_plugin->value['origin']['lon'] are not set mySQL will attempt a RADIANS function on ''. We can check it's not == ''. We cannot simply check !empty since lat/lng should be able to be 0.

public function getSourceValue($views_plugin) {
    return array(
      'latitude' => (isset($views_plugin->value) && $views_plugin->value['origin']['lat'] !== '') ? $views_plugin->value['origin']['lat'] : $views_plugin->options['geofield_proximity_manual']['lat'],
      'longitude' => (isset($views_plugin->value) && $views_plugin->value['origin']['lon'] !== '') ? $views_plugin->value['origin']['lon'] : $views_plugin->options['geofield_proximity_manual']['lon'],
    );
	}

I don't believe the previous patches should be performed since then all results will be shown if either the latitude or longitude is 0 (i.e. PHP's special definition of empty). This excludes a lot of equatorial countries and the people who lives exactly on Greenwich's longitude :)

I could be wrong but I need sleep now (I've already fixed the !empty part above after some rest :)).

I haven't check all the other plug-ins either.

cmonnow’s picture

Priority: Normal » Major
Status: Needs work » Active
socialnicheguru’s picture

Status: Active » Needs review
mgifford’s picture

Status: Needs review » Needs work

Moving this to "needs work" - the author of the last patch still reported "I still receive the error on view edit with the patch applied."

This does need to be reviewed though. The patch is over a year old and it's quite likely that other things have changed since then.

hypertext200’s picture

StatusFileSize
new1.16 KB

This fixed the SQL error and the patch rolled from the suggestion at comment #15.

mgifford’s picture

Status: Needs work » Needs review
jumpthattb’s picture

@gianfrasoft

Awesome! :)

afinnarn’s picture

I had an issue with this module containing the same error when the proximity location data was not filled in. My issue was with the manual filter plugin, and after applying this patch the errors went away.

For context, I am using the exposed filter to pass back data to the view after getting the current location of the user. If I put a default value in the filter, then on the first page load, the wrong data would be displayed...or if getting their data fails at least the default view without geolocation works and goes to a fallback.

So, since this patch works for me and seems to be a harmless change with just more error checking, I'm going to mark it as RTBC.

afinnarn’s picture

Status: Needs review » Reviewed & tested by the community
afinnarn’s picture

Forgot to say the patch I used was #19.

calefilm’s picture

I received this error after setting my "Source of Origin Point" to "Manually enter Point" and did not provide a default value. I don't believe I have a use case for this option but I just wanted to report that I received the error after successfully patching stable and dev versions.

poker10’s picture

Status: Reviewed & tested by the community » Needs review

As per #25, I think this needs more reviews.