MCPcopy
hub / github.com/golang/geo / shapeIndexDebugString

Function shapeIndexDebugString

s2/textformat_test.go:332–395  ·  view source on GitHub ↗

shapeIndexDebugString outputs the contents of this ShapeIndex in debug format. The index may contain Shapes of any type. Shapes are reordered if necessary so that all point geometry (shapes of dimension 0) are first, followed by all polyline geometry, followed by all polygon geometry.

(index *ShapeIndex, roundtripPrecision bool)

Source from the content-addressed store, hash-verified

330// if necessary so that all point geometry (shapes of dimension 0) are first,
331// followed by all polyline geometry, followed by all polygon geometry.
332func shapeIndexDebugString(index *ShapeIndex, roundtripPrecision bool) string {
333 var buf bytes.Buffer
334
335 for dim := 0; dim <= 2; dim++ {
336 if dim > 0 {
337 buf.WriteByte('#')
338 }
339
340 var count int
341
342 // Use shapes ordered by id rather than ranging over the
343 // index.shapes map to ensure that the ordering of shapes in the
344 // generated string matches the C++ generated strings.
345 for i := int32(0); i < index.nextID; i++ {
346 shape := index.Shape(i)
347 // Only use shapes that are still in the index and at the
348 // current geometry level we are outputting.
349 if shape == nil || shape.Dimension() != dim {
350 continue
351 }
352 if count > 0 {
353 buf.WriteString(" | ")
354 } else {
355 if dim > 0 {
356 buf.WriteString(" ")
357 } else {
358 buf.WriteString("")
359 }
360 }
361
362 for c := 0; c < shape.NumChains(); c++ {
363 if c > 0 {
364 if dim == 2 {
365 buf.WriteString("; ")
366 } else {
367 buf.WriteString(" | ")
368 }
369 }
370 chain := shape.Chain(c)
371 if chain.Length == 0 {
372 buf.WriteString("full")
373 } else {
374 writePoint(&buf, shape.Edge(chain.Start).V0, roundtripPrecision)
375 }
376 limit := chain.Start + chain.Length
377 if dim != 1 {
378 limit--
379 }
380
381 for e := chain.Start; e < limit; e++ {
382 buf.WriteString(", ")
383 writePoint(&buf, shape.Edge(e).V1, roundtripPrecision)
384 }
385 count++
386 }
387 }
388
389 if dim == 1 || (dim == 0 && count > 0) {

Calls 7

writePointFunction · 0.85
ShapeMethod · 0.80
DimensionMethod · 0.65
NumChainsMethod · 0.65
ChainMethod · 0.65
EdgeMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…