Code Monkey home page Code Monkey logo

Comments (5)

domesticmouse avatar domesticmouse commented on May 19, 2024 2

Honestly, the Contains functionality is outside the bounds of what this library is attempting to do, which is be an API client library.

I'd suggest looking http://tile38.com/ for a MIT licensed in-memory geolocation data store, spatial index, and realtime geofence service written in Go. =)

from google-maps-services-go.

domesticmouse avatar domesticmouse commented on May 19, 2024

We accept pull requests =)

from google-maps-services-go.

mblasi avatar mblasi commented on May 19, 2024

Sure! I'll try.

Do you have any reference implementation or mathematical theory to afford this problem?

Regards,
Matías.

from google-maps-services-go.

mblasi avatar mblasi commented on May 19, 2024

I think the answer over here: https://s2geometry.io/about/overview and https://godoc.org/github.com/golang/geo/s2

Continue researching...

Regards,
Matías.

from google-maps-services-go.

mblasi avatar mblasi commented on May 19, 2024

Just for contributing with someone else, this is how I resolved this:

func extendBounds(bounds1, bounds2 maps.LatLngBounds) maps.LatLngBounds {

	boundsPoints := []s2.Point{}
	point1 := s2.PointFromLatLng(s2.LatLngFromDegrees(bounds1.NorthEast.Lng, bounds1.NorthEast.Lat).Normalized())
	point2 := s2.PointFromLatLng(s2.LatLngFromDegrees(bounds1.SouthWest.Lng, bounds1.NorthEast.Lat).Normalized())
	point3 := s2.PointFromLatLng(s2.LatLngFromDegrees(bounds1.SouthWest.Lng, bounds1.SouthWest.Lat).Normalized())
	point4 := s2.PointFromLatLng(s2.LatLngFromDegrees(bounds1.NorthEast.Lng, bounds1.SouthWest.Lat).Normalized())
	boundsPoints = append(boundsPoints, point1, point2, point3, point4)
	point1 = s2.PointFromLatLng(s2.LatLngFromDegrees(bounds2.NorthEast.Lng, bounds2.NorthEast.Lat).Normalized())
	point2 = s2.PointFromLatLng(s2.LatLngFromDegrees(bounds2.SouthWest.Lng, bounds2.NorthEast.Lat).Normalized())
	point3 = s2.PointFromLatLng(s2.LatLngFromDegrees(bounds2.SouthWest.Lng, bounds2.SouthWest.Lat).Normalized())
	point4 = s2.PointFromLatLng(s2.LatLngFromDegrees(bounds2.NorthEast.Lng, bounds2.SouthWest.Lat).Normalized())
	boundsPoints = append(boundsPoints, point1, point2, point3, point4)
	loop := s2.LoopFromPoints(boundsPoints)
	loop.Normalize()

	rect := loop.RectBound()
	hi := rect.Hi()
	lo := rect.Lo()

	return maps.LatLngBounds{NorthEast: maps.LatLng{Lat: hi.Lat.Degrees(), Lng: hi.Lng.Degrees()}, SouthWest: maps.LatLng{Lat: lo.Lat.Degrees(), Lng: lo.Lng.Degrees()}}
}

from google-maps-services-go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.