diff --git a/datatypes.go b/datatypes.go index 2df3f60..c3b7752 100644 --- a/datatypes.go +++ b/datatypes.go @@ -15,7 +15,7 @@ import ( // float2-4 => [2]float - [4]float -var placementRegexp = regexp.MustCompile(`^\(([0-9.]+|&[0-9a-f]+), ([0-9.]+|&[0-9a-f]+), ([0-9.]+|&[0-9a-f]+)\) \(([0-9.]+|&[0-9a-f]+); ([0-9.]+|&[0-9a-f]+), ([0-9.]+|&[0-9a-f]+), ([0-9.]+|&[0-9a-f]+)\)$`) +var placementRegexp = regexp.MustCompile(`^\(([0-9.-]+|&[0-9a-f]+), ([0-9.-]+|&[0-9a-f]+), ([0-9.-]+|&[0-9a-f]+)\) \(([0-9.-]+|&[0-9a-f]+); ([0-9.-]+|&[0-9a-f]+), ([0-9.-]+|&[0-9a-f]+), ([0-9.-]+|&[0-9a-f]+)\)$`) // Placement contains 7 floats: (x, y, z) (w; x, y, z) type Placement [7]float32 diff --git a/genericUnmarshaller.go b/genericUnmarshaller.go index a6372f8..46ab90b 100644 --- a/genericUnmarshaller.go +++ b/genericUnmarshaller.go @@ -113,7 +113,7 @@ func genericUnmarshal(in []byte, out interface{}, unit *Unit) error { switch typeField.Type.Len() { case 3: - grps := regexp.MustCompile(`^\(([0-9.]+|&[0-9a-f]+), ([0-9.]+|&[0-9a-f]+), ([0-9.]+|&[0-9a-f]+)\)$`). + grps := regexp.MustCompile(`^\(([0-9.-]+|&[0-9a-f]+), ([0-9.-]+|&[0-9a-f]+), ([0-9.-]+|&[0-9a-f]+)\)$`). FindSubmatch(getSingleValue(in, attributeName)) var v [3]float32 diff --git a/helpers.go b/helpers.go index da4d48c..83d530d 100644 --- a/helpers.go +++ b/helpers.go @@ -17,7 +17,7 @@ func float2sii(f float32) ([]byte, error) { err error ) - if math.Floor(float64(f)) == float64(f) && f < 1000 { + if math.Floor(float64(f)) == float64(f) && f < 1000 && f > -1000 { return []byte(fmt.Sprintf("%.0f", f)), nil }