Index: trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoordsValue.php |
— | — | @@ -78,20 +78,23 @@ |
79 | 79 | if ( $value == '' ) { |
80 | 80 | $this->addError( wfMsg( 'smw_novalues' ) ); |
81 | 81 | } else { |
82 | | - // TODO: parse the parts here |
83 | 82 | SMWDataValue::prepareValue( $value, $comparator ); |
| 83 | + |
| 84 | + $parts = explode( '(', $value ); |
84 | 85 | |
85 | | - $parts = array(); |
86 | | - preg_match( '/(.*)\((.*)\)/', $value, $parts ); |
87 | | - |
88 | | - $coordinates = array_shift( $parts ); |
89 | | - $distance = count( $parts ) > 0 ? array_shift( $parts ) : false; |
90 | | - |
91 | | - if ( $distance !== false && !preg_match( '/^\d+(\.\d+)?$/', $distance ) ) { |
92 | | - $this->addError( wfMsgExt( 'semanticmaps-unrecognizeddistance', array( 'parsemag' ), $distance ) ); |
93 | | - $distance = false; |
| 86 | + $coordinates = trim( array_shift( $parts ) ); |
| 87 | + $distance = count( $parts ) > 0 ? trim( array_shift( $parts ) ) : false; |
| 88 | + |
| 89 | + if ( $distance !== false ) { |
| 90 | + if ( preg_match( '/^\d+(\.\d+)?\)$/', $distance ) ) { |
| 91 | + $distance = substr( $distance, 0, -1 ); |
| 92 | + } |
| 93 | + else { |
| 94 | + $this->addError( wfMsgExt( 'semanticmaps-unrecognizeddistance', array( 'parsemag' ), $distance ) ); |
| 95 | + $distance = false; |
| 96 | + } |
94 | 97 | } |
95 | | - |
| 98 | + |
96 | 99 | $parsedCoords = MapsCoordinateParser::parseCoordinates( $coordinates ); |
97 | 100 | if ( $parsedCoords ) { |
98 | 101 | $this->mCoordinateSet = $parsedCoords; |
Index: trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoordsValueDescription.php |
— | — | @@ -68,7 +68,6 @@ |
69 | 69 | $coordinates = $dataValue->getCoordinateSet(); |
70 | 70 | |
71 | 71 | $comparator = $description->getComparator() == SMW_CMP_EQ ? '=' : '!='; |
72 | | - //var_dump($comparator);exit; |
73 | 72 | |
74 | 73 | // TODO: The field names are hardcoded in, since SMW offers no support for selection based on multiple fields. |
75 | 74 | // Ideally SMW's setup should be changed to allow for this. Now the query can break when other extensions |
Index: trunk/extensions/SemanticMaps/GeoCoords/SM_AreaValueDescription.php |
— | — | @@ -26,9 +26,10 @@ |
27 | 27 | protected $mBounds = false; |
28 | 28 | |
29 | 29 | public function __construct( SMGeoCoordsValue $dataValue, $radius ) { |
30 | | - parent::__construct( $dataValue ); |
| 30 | + parent::__construct( $dataValue, SM_CMP_NEAR ); |
31 | 31 | |
32 | | - // If the MapsGeoFunctions class is not loaded, we can not create the bounding box, so don't add any conditions. |
| 32 | + // If the MapsGeoFunctions class is not loaded, we can not create the bounding box, |
| 33 | + // so don't add any conditions. |
33 | 34 | if ( self::geoFunctionsAreAvailable() ) { |
34 | 35 | $dbKeys = $dataValue->getDBkeys(); |
35 | 36 | |
— | — | @@ -88,11 +89,13 @@ |
89 | 90 | * @return An associative array containing the limits with keys north, east, south and west. |
90 | 91 | */ |
91 | 92 | private static function getBoundingBox( array $centerCoordinates, $circleRadius ) { |
| 93 | + $centerCoordinates = array('lat' => 0, 'lon' => 0); |
| 94 | + var_dump($centerCoordinates); |
92 | 95 | $north = MapsGeoFunctions::findDestination( $centerCoordinates, 0, $circleRadius ); |
93 | 96 | $east = MapsGeoFunctions::findDestination( $centerCoordinates, 90, $circleRadius ); |
94 | 97 | $south = MapsGeoFunctions::findDestination( $centerCoordinates, 180, $circleRadius ); |
95 | 98 | $west = MapsGeoFunctions::findDestination( $centerCoordinates, 270, $circleRadius ); |
96 | | - |
| 99 | +var_dump($north);var_dump($east);var_dump($south);var_dump($west);exit; |
97 | 100 | return array( |
98 | 101 | 'north' => $north['lat'], |
99 | 102 | 'east' => $east['lon'], |
— | — | @@ -105,8 +108,7 @@ |
106 | 109 | * Returns a boolean indicating if MapsGeoFunctions is available. |
107 | 110 | */ |
108 | 111 | private static function geoFunctionsAreAvailable() { |
109 | | - global $wgAutoloadClasses; |
110 | | - return array_key_exists( 'MapsGeoFunctions', $wgAutoloadClasses ); |
| 112 | + return class_exists( 'MapsGeoFunctions' ); |
111 | 113 | } |
112 | 114 | |
113 | 115 | /** |
— | — | @@ -122,7 +124,7 @@ |
123 | 125 | */ |
124 | 126 | public static function getSQLCondition( &$whereSQL, SMWDescription $description, $tablename, $fieldname, DatabaseBase $dbs ) { |
125 | 127 | $dataValue = $description->getDatavalue(); |
126 | | - |
| 128 | + |
127 | 129 | // Only execute the query when the description's type is geographical coordinates, |
128 | 130 | // the description is valid, and the near comparator is used. |
129 | 131 | if ( $dataValue->getTypeID() != '_geo' |
— | — | @@ -136,12 +138,12 @@ |
137 | 139 | $east = $dbs->addQuotes( $boundingBox['east'] ); |
138 | 140 | $south = $dbs->addQuotes( $boundingBox['south'] ); |
139 | 141 | $west = $dbs->addQuotes( $boundingBox['west'] ); |
140 | | - |
| 142 | + |
141 | 143 | // TODO: The field names are hardcoded in, since SMW offers no support for selection based on multiple fields. |
142 | 144 | // Ideally SMW's setup should be changed to allow for this. Now the query can break when other extensions |
143 | 145 | // add their own semantic tables with similar signatures. |
144 | 146 | $whereSQL .= "{$tablename}.lat < $north && {$tablename}.lat > $south && {$tablename}.lon < $east && {$tablename}.lon > $west"; |
145 | | - |
| 147 | +var_dump($whereSQL);exit; |
146 | 148 | return true; |
147 | 149 | } |
148 | 150 | } |
\ No newline at end of file |