|
| 1 | +// This file was generated by Mendix Modeler. |
| 2 | +// |
| 3 | +// WARNING: Only the following code will be retained when actions are regenerated: |
| 4 | +// - the import list |
| 5 | +// - the code between BEGIN USER CODE and END USER CODE |
| 6 | +// - the code between BEGIN EXTRA CODE and END EXTRA CODE |
| 7 | +// Other code you write will be lost the next time you deploy the project. |
| 8 | +// Special characters, e.g., é, ö, à, etc. are supported in comments. |
| 9 | + |
| 10 | +package redisconnector.actions; |
| 11 | + |
| 12 | +import com.mendix.systemwideinterfaces.core.IContext; |
| 13 | +import com.mendix.webui.CustomJavaAction; |
| 14 | +import redisconnector.impl.RedisConnector; |
| 15 | + |
| 16 | +/** |
| 17 | + * GEOADD key longitude latitude member [longitude latitude member ...] |
| 18 | + * |
| 19 | + * Available since 3.2.0. |
| 20 | + * Time complexity: O(log(N)) for each item added, where N is the number of elements in the sorted set. |
| 21 | + * Adds the specified geospatial items (latitude, longitude, name) to the specified key. Data is stored into the key as a sorted set, in a way that makes it possible to later retrieve items using a query by radius with the GEORADIUS or GEORADIUSBYMEMBER commands. |
| 22 | + * The command takes arguments in the standard format x,y so the longitude must be specified before the latitude. There are limits to the coordinates that can be indexed: areas very near to the poles are not indexable. The exact limits, as specified by EPSG:900913 / EPSG:3785 / OSGEO:41001 are the following: |
| 23 | + * Valid longitudes are from -180 to 180 degrees. |
| 24 | + * Valid latitudes are from -85.05112878 to 85.05112878 degrees. |
| 25 | + * The command will report an error when the user attempts to index coordinates outside the specified ranges. |
| 26 | + * Note: there is no GEODEL command because you can use ZREM in order to remove elements. The Geo index structure is just a sorted set. |
| 27 | + */ |
| 28 | +public class AddGeoPosition extends CustomJavaAction<Boolean> |
| 29 | +{ |
| 30 | + private String Key; |
| 31 | + private java.math.BigDecimal Latitude; |
| 32 | + private java.math.BigDecimal Longitude; |
| 33 | + private String Name; |
| 34 | + |
| 35 | + public AddGeoPosition(IContext context, String Key, java.math.BigDecimal Latitude, java.math.BigDecimal Longitude, String Name) |
| 36 | + { |
| 37 | + super(context); |
| 38 | + this.Key = Key; |
| 39 | + this.Latitude = Latitude; |
| 40 | + this.Longitude = Longitude; |
| 41 | + this.Name = Name; |
| 42 | + } |
| 43 | + |
| 44 | + @Override |
| 45 | + public Boolean executeAction() throws Exception |
| 46 | + { |
| 47 | + // BEGIN USER CODE |
| 48 | + RedisConnector redisconnector = new RedisConnector(); |
| 49 | + |
| 50 | + double LatitudeConverted = Latitude.doubleValue(); |
| 51 | + double LongitudeConverted = Longitude.doubleValue(); |
| 52 | + |
| 53 | + redisconnector.geoadd(Key, LatitudeConverted, LongitudeConverted, Name); |
| 54 | + return true; |
| 55 | + // END USER CODE |
| 56 | + } |
| 57 | + |
| 58 | + /** |
| 59 | + * Returns a string representation of this action |
| 60 | + */ |
| 61 | + @Override |
| 62 | + public String toString() |
| 63 | + { |
| 64 | + return "AddGeoPosition"; |
| 65 | + } |
| 66 | + |
| 67 | + // BEGIN EXTRA CODE |
| 68 | + // END EXTRA CODE |
| 69 | +} |
0 commit comments