Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a problem of distanceLineAndLine #58

Closed
radi2015 opened this issue Jan 20, 2022 · 2 comments
Closed

a problem of distanceLineAndLine #58

radi2015 opened this issue Jan 20, 2022 · 2 comments

Comments

@radi2015
Copy link

radi2015 commented Jan 20, 2022

	line0 := space.LineString{{116.40495300292967, 39.926785883895654}, {116.3975715637207, 39.9295502919}}
	line1 := space.LineString{{116.37310981750488, 39.92099342895789}, {116.39928817749023, 39.9174387253541}}
	fmt.Println(line1.Distance(line0))

0 <nil>

dist is initialized with 0, this for impossible in
if distP, _ := elem.Distance(); dist > distP {
dist = distP
}

var dist float64
modified with
var dist float64 = math.MaxFloat64


修改问题源码
func (el *ElementDistance) distanceLineAndLine() (float64, error) {
	var dist float64 
	if mark := relate.IsIntersectionEdge(el.From.(matrix.LineMatrix), el.To.(matrix.LineMatrix)); mark {
		return 0, nil
	}
	for _, v := range el.From.(matrix.LineMatrix) {
		elem := &ElementDistance{matrix.Matrix(v), el.To, el.F}
		if distP, _ := elem.Distance(); dist > distP {
			dist = distP
		}
	}
	return dist, nil
}
@xiaogu-space
Copy link
Contributor

thanks,we will fix it recently

@xiaogu-space
Copy link
Contributor

we have fix it ,you can use the latest code in branch main, and we will release new version recently

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants