geospatial

Parsing latitude and longitude with Ruby

我们两清 提交于 2019-12-22 06:02:57
问题 I need to parse some user submitted strings containing latitudes and longitudes, under Ruby. The result should be given in a double Example: 08º 04' 49'' 09º 13' 12'' Result: 8.080278 9.22 I've looked to both Geokit and GeoRuby but haven't found a solution. Any hint? 回答1: "08° 04' 49'' 09° 13' 12''".gsub(/(\d+)° (\d+)' (\d+)''/) do $1.to_f + $2.to_f/60 + $3.to_f/3600 end #=> "8.08027777777778 9.22" Edit: or to get the result as an array of floats: "08° 04' 49'' 09° 13' 12''".scan(/(\d+)° (\d+

GeoSpatial Radius Search Using Objectify

谁说我不能喝 提交于 2019-12-22 05:19:26
问题 I am developing an application using GeoModel. I need to perform search in a particular radius based on the given latitude and longitude. I am able to generate the GeoCells in the datastore using Objectify, but not able to get back the results in a particular radius. I am sharing my code below. Entity Class @Entity public class NewsFeed implements Serializable { private static final long serialVersionUID = 1L; @Id @Index private Long feedID; @Index private String topic; @Index private String

Create a grid inside a shapefile

早过忘川 提交于 2019-12-21 23:20:04
问题 I am trying to crate a grid inside a shapefile, something like this. However, I am unable to generate such grid. I was wondering if anyone has an idea on how to accomplish this. Here is my code - WWWL.Shape<- readOGR("E:/Juan Arango", "WWL_Commerce_OK") WWWL.Shape plot(WWWL.Shape) proj4string(WWWL.Shape) bb <- bbox(WWWL.Shape) cs <- c(3.28084, 3.28084)*6000 # cell size cc <- bb[, 1] + (cs/2) # cell offset cd <- ceiling(diff(t(bb))/cs) # number of cells per direction grd <- GridTopology

Find land mass nearest to a geo coordinate

末鹿安然 提交于 2019-12-21 22:17:28
问题 As part of a developer challenge, I am trying to determine the land mass closest to a given coordinate. Obviously, if the point is on land, I use reverse geocoding and can get details. The problem is that if the point is in a body of water, especially oceans, it often won't return anything (Google, Nokia, Bing). I'd like to know that a point 3 miles off the coast of California is 3 miles from USA, or x miles from Japan, y miles from South Korea when a point is reasonably near more than one

How do I insert a mysql spatial point with a yii model?

梦想的初衷 提交于 2019-12-21 20:44:30
问题 I have a model type that was generated from a mysql table that has address data and also a spatial POINT field named "coordinates". When a model is created or updated I want to geocode the address and store the latitude and longitude coordinates in the POINT field. My understanding is the way to do this is to geocode the address in the model's beforeSave method. I have done this and have the coordinates in an associative array. Now my question is how can I insert this data into my coordinates

Filter Documents by Distance Stored in Document with $near

陌路散爱 提交于 2019-12-21 19:51:22
问题 I am using the following example to better explain my need. I have a set of points(users) on a map and collection schema is as below { location:{ latlong:[long,lat] }, maxDistance:Number } i have another collection with events happening in the area. schema is given below { eventLocation:{ latlong:[long,lat] } } now users can add their location and the maximum distance they want to travel for to attend an event and save it. whenever a new event is posted , all the users satisfying their

Why can't I insert into MySQL?

淺唱寂寞╮ 提交于 2019-12-21 16:23:18
问题 +---------+---------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------+---------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | user_id | int(11) | NO | UNI | NULL | | | utm | point | NO | MUL | NULL | | +---------+---------+------+-----+---------+----------------+ insert into life(user_id, utm) values(99,point(4,4)); ERROR 1416 (22003): Cannot get geometry object from data you send to the

Error when using Spatial Index in SQL Server

烈酒焚心 提交于 2019-12-21 14:33:09
问题 I use Spatial Index and when I try to execute WHERE statement: WHERE T.GEOMETRY.STIntersects(O.GEOMETRY) = 1 AND T.GEOMETRY.STTouches(O.GEOMETRY) = 0 It works fine, but when I try to execute with OR: WHERE T.GEOMETRY.STOverlaps(O.GEOMETRY) = 1 OR T.GEOMETRY.STWithin(O.GEOMETRY) = 1 I get this error: The query processor could not produce a query plan for a query with a spatial index hint. Reason: Could not find required binary spatial method in a condition. Try removing the index hints or

Handling Mysql Spatial datatypes in Laravel Eloquent ORM

孤人 提交于 2019-12-21 06:57:59
问题 How to handle mysql spatial datatypes in eloquent ORM?, This include how to create migration, insert spatial data and performing spatial query's. If there is not actual solutions exists, is there any workarounds? 回答1: A workaround I have implemented a while ago is to have a latitude and longitude fields on the model with the following validations (see Validator class): $rules = array('latitude' => 'required|numeric|between:-90,90', 'longitude'=>'required|numeric|between:-180,180',) The magic

Insert a circle into geometry data type

折月煮酒 提交于 2019-12-21 06:34:50
问题 I'm about to start using geometry or geography data types for the first time now that we have a development baseline of 2008R2 (!) I'm struggling to find how to store the representation for a circle. We currently have the lat and long of the centre of the circle along with the radius, something like :- [Lat] [float] NOT NULL, [Long] [float] NOT NULL, [Radius] [decimal](9, 4) NOT NULL, Does anyone know the equivalent way to store this using the STGeomFromText method, ie which Well-Known Text