Index: trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoordsValue.php |
— | — | @@ -14,8 +14,8 @@ |
15 | 15 | die( 'Not an entry point.' ); |
16 | 16 | } |
17 | 17 | |
18 | | -// / Unicode symbols for coordinate minutes and seconds; |
19 | | -// / may not display in every font ... |
| 18 | +/// Unicode symbols for coordinate minutes and seconds; |
| 19 | +/// may not display in every font ... |
20 | 20 | define( 'SM_GEO_MIN', '′' ); |
21 | 21 | define( 'SM_GEO_SEC', '″' ); |
22 | 22 | |
— | — | @@ -44,6 +44,16 @@ |
45 | 45 | // Note: signs are used as e.g. on Google maps, i.e. S and W are negative numbers. |
46 | 46 | |
47 | 47 | /** |
| 48 | + * Adds support for the geographical coordinate data type to Semantic MediaWiki. |
| 49 | + * |
| 50 | + * TODO: i18n keys still need to be moved |
| 51 | + */ |
| 52 | + function InitGeoCoordsType() { |
| 53 | + SMWDataValueFactory::registerDatatype( '_geo', 'SMGeoCoordsValue', 'Geographic coordinate' ); |
| 54 | + return true; |
| 55 | + } |
| 56 | + |
| 57 | + /** |
48 | 58 | * @see SMWDataValue::parseUserValue |
49 | 59 | */ |
50 | 60 | protected function parseUserValue( $value ) { |
— | — | @@ -85,7 +95,12 @@ |
86 | 96 | $value = str_replace( array( '′', '′', "'", '´' ), SM_GEO_MIN, $value ); |
87 | 97 | |
88 | 98 | // Split the value string. |
89 | | - $parts = preg_split( '/\s*(°|' . SM_GEO_MIN . '|' . SM_GEO_SEC . '|N|E|W|S|;)\s*/u', str_replace( ', ', ';', $value ) . ';', - 1, PREG_SPLIT_DELIM_CAPTURE ); |
| 99 | + $parts = preg_split( |
| 100 | + '/\s*(°|' . SM_GEO_MIN . '|' . SM_GEO_SEC . '|N|E|W|S|;)\s*/u', |
| 101 | + str_replace( ', ', ';', $value ) . ';', |
| 102 | + - 1, |
| 103 | + PREG_SPLIT_DELIM_CAPTURE |
| 104 | + ); |
90 | 105 | $curnum = false; |
91 | 106 | $angles = array( false, false, false ); // Temporary values for deg, min, sec |
92 | 107 | |
Index: trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoords.php |
— | — | @@ -18,22 +18,13 @@ |
19 | 19 | $wgAutoloadClasses['SMGeoCoordsValueDescription'] = $smgDir . 'GeoCoords/SM_GeoCoordsValueDescription.php'; |
20 | 20 | |
21 | 21 | // Hook for initializing the Geographical Coordinate type. |
22 | | -$wgHooks['smwInitDatatypes'][] = 'smfInitGeoCoordsType'; |
| 22 | +$wgHooks['smwInitDatatypes'][] = 'SMGeoCoordsValue::InitGeoCoordsType'; |
23 | 23 | |
24 | 24 | // Hook for initializing the Geographical Proximity query support. |
25 | 25 | $wgHooks['smwGetSQLConditionForValue'][] = 'smfGetGeoProximitySQLCondition'; |
26 | 26 | |
27 | 27 | define( 'SM_CMP_NEAR', 101 ); // Define the near comparator for proximity queries. |
28 | 28 | |
29 | | -/** |
30 | | - * Adds support for the geographical coordinate data type to Semantic MediaWiki. |
31 | | - * |
32 | | - * TODO: i18n keys still need to be moved |
33 | | - */ |
34 | | -function smfInitGeoCoordsType() { |
35 | | - SMWDataValueFactory::registerDatatype( '_geo', 'SMGeoCoordsValue', 'Geographic coordinate' ); |
36 | | - return true; |
37 | | -} |
38 | 29 | |
39 | 30 | /** |
40 | 31 | * Custom SQL query extension for matching geographic coordinates. |
— | — | @@ -44,6 +35,8 @@ |
45 | 36 | * TODO: Add support for a per-coordinate set distance parameter. |
46 | 37 | */ |
47 | 38 | function smfGetGeoProximitySQLCondition( &$where, $description, $tablename, $fieldname, $dbs ) { |
| 39 | + global $smgGeoCoordDistance; |
| 40 | + |
48 | 41 | $where = ''; |
49 | 42 | $dv = $description->getDatavalue(); |
50 | 43 | |
— | — | @@ -68,7 +61,7 @@ |
69 | 62 | // Compute distances in miles: |
70 | 63 | $distance = "ROUND(((ACOS( SIN({$latitude} * PI()/180 ) * SIN(SUBSTRING_INDEX({$tablename}.{$fieldname}, ',',1) * PI()/180 ) + COS({$latitude} * PI()/180 ) * COS(SUBSTRING_INDEX({$tablename}.{$fieldname}, ',',1) * PI()/180 ) * COS(({$longitude} - SUBSTRING_INDEX({$tablename}.{$fieldname}, ',',-1)) * PI()/180))*180/PI())*60*1.1515),6)"; |
71 | 64 | |
72 | | - $where = "{$distance} <= " . $dbs->addQuotes( "5" ); |
| 65 | + $where = "{$distance} <= " . $dbs->addQuotes( $smgGeoCoordDistance ); |
73 | 66 | |
74 | 67 | return true; |
75 | 68 | } |
\ No newline at end of file |
Index: trunk/extensions/SemanticMaps/FormInputs/SM_FormInput.php |
— | — | @@ -148,7 +148,7 @@ |
149 | 149 | } |
150 | 150 | else { |
151 | 151 | // Geocode and convert if required. |
152 | | - $centre = MapsGeocodeUtils::attemptToGeocode( $this->centre, $this->geoservice, $this->serviceName ); |
| 152 | + $centre = MapsGeocoder::attemptToGeocode( $this->centre, $this->geoservice, $this->serviceName ); |
153 | 153 | $centre = MapsUtils::getLatLon( $centre ); |
154 | 154 | |
155 | 155 | $this->centre_lat = Xml::escapeJsString( $centre['lat'] ); |
Index: trunk/extensions/SemanticMaps/SemanticMaps.php |
— | — | @@ -35,7 +35,7 @@ |
36 | 36 | |
37 | 37 | // Only initialize the extension when all dependencies are present. |
38 | 38 | if ( defined( 'Maps_VERSION' ) && defined( 'SMW_VERSION' ) ) { |
39 | | - define( 'SM_VERSION', '0.5.5' ); |
| 39 | + define( 'SM_VERSION', '0.5.6' ); |
40 | 40 | |
41 | 41 | $smgScriptPath = ( isset( $wgExtensionAssetsPath ) && $wgExtensionAssetsPath ? $wgExtensionAssetsPath : $wgScriptPath . '/extensions' ) . '/SemanticMaps'; |
42 | 42 | $smgDir = dirname( __FILE__ ) . '/'; |
Index: trunk/extensions/SemanticMaps/QueryPrinters/SM_MapPrinter.php |
— | — | @@ -303,7 +303,7 @@ |
304 | 304 | // If a centre value is set, use it. |
305 | 305 | if ( strlen( $this->centre ) > 0 ) { |
306 | 306 | // Geocode and convert if required. |
307 | | - $centre = MapsGeocodeUtils::attemptToGeocode( $this->centre, $this->geoservice, $this->serviceName ); |
| 307 | + $centre = MapsGeocoder::attemptToGeocode( $this->centre, $this->geoservice, $this->serviceName ); |
308 | 308 | $centre = MapsUtils::getLatLon( $centre ); |
309 | 309 | |
310 | 310 | $this->centre_lat = $centre['lat']; |