repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
nats-io/go-nats-streaming
stan.go
cleanupOnClose
func (sc *conn) cleanupOnClose(err error) { sc.pingMu.Lock() if sc.pingTimer != nil { sc.pingTimer.Stop() sc.pingTimer = nil } sc.pingMu.Unlock() // Unsubscribe only if the NATS connection is not already closed // and we don't own it (otherwise connection is going to be closed // so no need for explicit unsubscribe). if !sc.ncOwned && !sc.nc.IsClosed() { if sc.hbSubscription != nil { sc.hbSubscription.Unsubscribe() } if sc.pingSub != nil { sc.pingSub.Unsubscribe() } if sc.ackSubscription != nil { sc.ackSubscription.Unsubscribe() } } // Fail all pending pubs for guid, pubAck := range sc.pubAckMap { if pubAck.t != nil { pubAck.t.Stop() } if pubAck.ah != nil { pubAck.ah(guid, err) } else if pubAck.ch != nil { pubAck.ch <- err } delete(sc.pubAckMap, guid) if len(sc.pubAckChan) > 0 { <-sc.pubAckChan } } }
go
func (sc *conn) cleanupOnClose(err error) { sc.pingMu.Lock() if sc.pingTimer != nil { sc.pingTimer.Stop() sc.pingTimer = nil } sc.pingMu.Unlock() // Unsubscribe only if the NATS connection is not already closed // and we don't own it (otherwise connection is going to be closed // so no need for explicit unsubscribe). if !sc.ncOwned && !sc.nc.IsClosed() { if sc.hbSubscription != nil { sc.hbSubscription.Unsubscribe() } if sc.pingSub != nil { sc.pingSub.Unsubscribe() } if sc.ackSubscription != nil { sc.ackSubscription.Unsubscribe() } } // Fail all pending pubs for guid, pubAck := range sc.pubAckMap { if pubAck.t != nil { pubAck.t.Stop() } if pubAck.ah != nil { pubAck.ah(guid, err) } else if pubAck.ch != nil { pubAck.ch <- err } delete(sc.pubAckMap, guid) if len(sc.pubAckChan) > 0 { <-sc.pubAckChan } } }
[ "func", "(", "sc", "*", "conn", ")", "cleanupOnClose", "(", "err", "error", ")", "{", "sc", ".", "pingMu", ".", "Lock", "(", ")", "\n", "if", "sc", ".", "pingTimer", "!=", "nil", "{", "sc", ".", "pingTimer", ".", "Stop", "(", ")", "\n", "sc", "...
// Do some cleanup when connection is lost or closed. // Connection lock is held on entry, and sc.nc is guaranteed not to be nil.
[ "Do", "some", "cleanup", "when", "connection", "is", "lost", "or", "closed", ".", "Connection", "lock", "is", "held", "on", "entry", "and", "sc", ".", "nc", "is", "guaranteed", "not", "to", "be", "nil", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/stan.go#L551-L588
train
nats-io/go-nats-streaming
stan.go
Close
func (sc *conn) Close() error { sc.Lock() defer sc.Unlock() if sc.nc == nil { // We are already closed. return nil } // Capture for NATS calls below. nc := sc.nc if sc.ncOwned { defer nc.Close() } // Now close ourselves. sc.cleanupOnClose(ErrConnectionClosed) // Signals we are closed. // Do this also under pingMu lock so that we don't need // to grab sc's lock in pingServer. sc.pingMu.Lock() sc.nc = nil sc.pingMu.Unlock() req := &pb.CloseRequest{ClientID: sc.clientID} b, _ := req.Marshal() reply, err := nc.Request(sc.closeRequests, b, sc.opts.ConnectTimeout) if err != nil { if err == nats.ErrTimeout { return ErrCloseReqTimeout } return err } cr := &pb.CloseResponse{} err = cr.Unmarshal(reply.Data) if err != nil { return err } if cr.Error != "" { return errors.New(cr.Error) } return nil }
go
func (sc *conn) Close() error { sc.Lock() defer sc.Unlock() if sc.nc == nil { // We are already closed. return nil } // Capture for NATS calls below. nc := sc.nc if sc.ncOwned { defer nc.Close() } // Now close ourselves. sc.cleanupOnClose(ErrConnectionClosed) // Signals we are closed. // Do this also under pingMu lock so that we don't need // to grab sc's lock in pingServer. sc.pingMu.Lock() sc.nc = nil sc.pingMu.Unlock() req := &pb.CloseRequest{ClientID: sc.clientID} b, _ := req.Marshal() reply, err := nc.Request(sc.closeRequests, b, sc.opts.ConnectTimeout) if err != nil { if err == nats.ErrTimeout { return ErrCloseReqTimeout } return err } cr := &pb.CloseResponse{} err = cr.Unmarshal(reply.Data) if err != nil { return err } if cr.Error != "" { return errors.New(cr.Error) } return nil }
[ "func", "(", "sc", "*", "conn", ")", "Close", "(", ")", "error", "{", "sc", ".", "Lock", "(", ")", "\n", "defer", "sc", ".", "Unlock", "(", ")", "\n\n", "if", "sc", ".", "nc", "==", "nil", "{", "// We are already closed.", "return", "nil", "\n", ...
// Close a connection to the stan system.
[ "Close", "a", "connection", "to", "the", "stan", "system", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/stan.go#L591-L634
train
nats-io/go-nats-streaming
stan.go
NatsConn
func (sc *conn) NatsConn() *nats.Conn { sc.RLock() nc := sc.nc sc.RUnlock() return nc }
go
func (sc *conn) NatsConn() *nats.Conn { sc.RLock() nc := sc.nc sc.RUnlock() return nc }
[ "func", "(", "sc", "*", "conn", ")", "NatsConn", "(", ")", "*", "nats", ".", "Conn", "{", "sc", ".", "RLock", "(", ")", "\n", "nc", ":=", "sc", ".", "nc", "\n", "sc", ".", "RUnlock", "(", ")", "\n", "return", "nc", "\n", "}" ]
// NatsConn returns the underlying NATS conn. Use this with care. For example, // closing the wrapped NATS conn will put the NATS Streaming Conn in an invalid // state.
[ "NatsConn", "returns", "the", "underlying", "NATS", "conn", ".", "Use", "this", "with", "care", ".", "For", "example", "closing", "the", "wrapped", "NATS", "conn", "will", "put", "the", "NATS", "Streaming", "Conn", "in", "an", "invalid", "state", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/stan.go#L639-L644
train
nats-io/go-nats-streaming
stan.go
processHeartBeat
func (sc *conn) processHeartBeat(m *nats.Msg) { // No payload assumed, just reply. sc.RLock() nc := sc.nc sc.RUnlock() if nc != nil { nc.Publish(m.Reply, nil) } }
go
func (sc *conn) processHeartBeat(m *nats.Msg) { // No payload assumed, just reply. sc.RLock() nc := sc.nc sc.RUnlock() if nc != nil { nc.Publish(m.Reply, nil) } }
[ "func", "(", "sc", "*", "conn", ")", "processHeartBeat", "(", "m", "*", "nats", ".", "Msg", ")", "{", "// No payload assumed, just reply.", "sc", ".", "RLock", "(", ")", "\n", "nc", ":=", "sc", ".", "nc", "\n", "sc", ".", "RUnlock", "(", ")", "\n", ...
// Process a heartbeat from the NATS Streaming cluster
[ "Process", "a", "heartbeat", "from", "the", "NATS", "Streaming", "cluster" ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/stan.go#L647-L655
train
nats-io/go-nats-streaming
stan.go
processAck
func (sc *conn) processAck(m *nats.Msg) { pa := &pb.PubAck{} err := pa.Unmarshal(m.Data) if err != nil { panic(fmt.Errorf("error during ack unmarshal: %v", err)) } // Remove a := sc.removeAck(pa.Guid) if a != nil { // Capture error if it exists. if pa.Error != "" { err = errors.New(pa.Error) } if a.ah != nil { // Perform the ackHandler callback a.ah(pa.Guid, err) } else if a.ch != nil { // Send to channel directly a.ch <- err } } }
go
func (sc *conn) processAck(m *nats.Msg) { pa := &pb.PubAck{} err := pa.Unmarshal(m.Data) if err != nil { panic(fmt.Errorf("error during ack unmarshal: %v", err)) } // Remove a := sc.removeAck(pa.Guid) if a != nil { // Capture error if it exists. if pa.Error != "" { err = errors.New(pa.Error) } if a.ah != nil { // Perform the ackHandler callback a.ah(pa.Guid, err) } else if a.ch != nil { // Send to channel directly a.ch <- err } } }
[ "func", "(", "sc", "*", "conn", ")", "processAck", "(", "m", "*", "nats", ".", "Msg", ")", "{", "pa", ":=", "&", "pb", ".", "PubAck", "{", "}", "\n", "err", ":=", "pa", ".", "Unmarshal", "(", "m", ".", "Data", ")", "\n", "if", "err", "!=", ...
// Process an ack from the NATS Streaming cluster
[ "Process", "an", "ack", "from", "the", "NATS", "Streaming", "cluster" ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/stan.go#L658-L680
train
nats-io/go-nats-streaming
stan.go
Publish
func (sc *conn) Publish(subject string, data []byte) error { // Need to make this a buffered channel of 1 in case // a publish call is blocked in pubAckChan but cleanupOnClose() // is trying to push the error to this channel. ch := make(chan error, 1) _, err := sc.publishAsync(subject, data, nil, ch) if err == nil { err = <-ch } return err }
go
func (sc *conn) Publish(subject string, data []byte) error { // Need to make this a buffered channel of 1 in case // a publish call is blocked in pubAckChan but cleanupOnClose() // is trying to push the error to this channel. ch := make(chan error, 1) _, err := sc.publishAsync(subject, data, nil, ch) if err == nil { err = <-ch } return err }
[ "func", "(", "sc", "*", "conn", ")", "Publish", "(", "subject", "string", ",", "data", "[", "]", "byte", ")", "error", "{", "// Need to make this a buffered channel of 1 in case", "// a publish call is blocked in pubAckChan but cleanupOnClose()", "// is trying to push the err...
// Publish will publish to the cluster and wait for an ACK.
[ "Publish", "will", "publish", "to", "the", "cluster", "and", "wait", "for", "an", "ACK", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/stan.go#L683-L693
train
nats-io/go-nats-streaming
stan.go
PublishAsync
func (sc *conn) PublishAsync(subject string, data []byte, ah AckHandler) (string, error) { return sc.publishAsync(subject, data, ah, nil) }
go
func (sc *conn) PublishAsync(subject string, data []byte, ah AckHandler) (string, error) { return sc.publishAsync(subject, data, ah, nil) }
[ "func", "(", "sc", "*", "conn", ")", "PublishAsync", "(", "subject", "string", ",", "data", "[", "]", "byte", ",", "ah", "AckHandler", ")", "(", "string", ",", "error", ")", "{", "return", "sc", ".", "publishAsync", "(", "subject", ",", "data", ",", ...
// PublishAsync will publish to the cluster on pubPrefix+subject and asynchronously // process the ACK or error state. It will return the GUID for the message being sent.
[ "PublishAsync", "will", "publish", "to", "the", "cluster", "on", "pubPrefix", "+", "subject", "and", "asynchronously", "process", "the", "ACK", "or", "error", "state", ".", "It", "will", "return", "the", "GUID", "for", "the", "message", "being", "sent", "." ...
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/stan.go#L697-L699
train
nats-io/go-nats-streaming
stan.go
processMsg
func (sc *conn) processMsg(raw *nats.Msg) { msg := &Msg{} err := msg.Unmarshal(raw.Data) if err != nil { panic(fmt.Errorf("error processing unmarshal for msg: %v", err)) } // Lookup the subscription sc.RLock() nc := sc.nc isClosed := nc == nil sub := sc.subMap[raw.Subject] sc.RUnlock() // Check if sub is no longer valid or connection has been closed. if sub == nil || isClosed { return } // Store in msg for backlink msg.Sub = sub sub.RLock() cb := sub.cb ackSubject := sub.ackInbox isManualAck := sub.opts.ManualAcks subsc := sub.sc // Can be nil if sub has been unsubscribed. sub.RUnlock() // Perform the callback if cb != nil && subsc != nil { cb(msg) } // Process auto-ack if !isManualAck && nc != nil { ack := &pb.Ack{Subject: msg.Subject, Sequence: msg.Sequence} b, _ := ack.Marshal() // FIXME(dlc) - Async error handler? Retry? nc.Publish(ackSubject, b) } }
go
func (sc *conn) processMsg(raw *nats.Msg) { msg := &Msg{} err := msg.Unmarshal(raw.Data) if err != nil { panic(fmt.Errorf("error processing unmarshal for msg: %v", err)) } // Lookup the subscription sc.RLock() nc := sc.nc isClosed := nc == nil sub := sc.subMap[raw.Subject] sc.RUnlock() // Check if sub is no longer valid or connection has been closed. if sub == nil || isClosed { return } // Store in msg for backlink msg.Sub = sub sub.RLock() cb := sub.cb ackSubject := sub.ackInbox isManualAck := sub.opts.ManualAcks subsc := sub.sc // Can be nil if sub has been unsubscribed. sub.RUnlock() // Perform the callback if cb != nil && subsc != nil { cb(msg) } // Process auto-ack if !isManualAck && nc != nil { ack := &pb.Ack{Subject: msg.Subject, Sequence: msg.Sequence} b, _ := ack.Marshal() // FIXME(dlc) - Async error handler? Retry? nc.Publish(ackSubject, b) } }
[ "func", "(", "sc", "*", "conn", ")", "processMsg", "(", "raw", "*", "nats", ".", "Msg", ")", "{", "msg", ":=", "&", "Msg", "{", "}", "\n", "err", ":=", "msg", ".", "Unmarshal", "(", "raw", ".", "Data", ")", "\n", "if", "err", "!=", "nil", "{"...
// Process an msg from the NATS Streaming cluster
[ "Process", "an", "msg", "from", "the", "NATS", "Streaming", "cluster" ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/stan.go#L794-L834
train
nats-io/go-nats-streaming
sub.go
MaxInflight
func MaxInflight(m int) SubscriptionOption { return func(o *SubscriptionOptions) error { o.MaxInflight = m return nil } }
go
func MaxInflight(m int) SubscriptionOption { return func(o *SubscriptionOptions) error { o.MaxInflight = m return nil } }
[ "func", "MaxInflight", "(", "m", "int", ")", "SubscriptionOption", "{", "return", "func", "(", "o", "*", "SubscriptionOptions", ")", "error", "{", "o", ".", "MaxInflight", "=", "m", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// MaxInflight is an Option to set the maximum number of messages the cluster will send // without an ACK.
[ "MaxInflight", "is", "an", "Option", "to", "set", "the", "maximum", "number", "of", "messages", "the", "cluster", "will", "send", "without", "an", "ACK", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/sub.go#L139-L144
train
nats-io/go-nats-streaming
sub.go
AckWait
func AckWait(t time.Duration) SubscriptionOption { return func(o *SubscriptionOptions) error { o.AckWait = t return nil } }
go
func AckWait(t time.Duration) SubscriptionOption { return func(o *SubscriptionOptions) error { o.AckWait = t return nil } }
[ "func", "AckWait", "(", "t", "time", ".", "Duration", ")", "SubscriptionOption", "{", "return", "func", "(", "o", "*", "SubscriptionOptions", ")", "error", "{", "o", ".", "AckWait", "=", "t", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// AckWait is an Option to set the timeout for waiting for an ACK from the cluster's // point of view for delivered messages.
[ "AckWait", "is", "an", "Option", "to", "set", "the", "timeout", "for", "waiting", "for", "an", "ACK", "from", "the", "cluster", "s", "point", "of", "view", "for", "delivered", "messages", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/sub.go#L148-L153
train
nats-io/go-nats-streaming
sub.go
StartAt
func StartAt(sp pb.StartPosition) SubscriptionOption { return func(o *SubscriptionOptions) error { o.StartAt = sp return nil } }
go
func StartAt(sp pb.StartPosition) SubscriptionOption { return func(o *SubscriptionOptions) error { o.StartAt = sp return nil } }
[ "func", "StartAt", "(", "sp", "pb", ".", "StartPosition", ")", "SubscriptionOption", "{", "return", "func", "(", "o", "*", "SubscriptionOptions", ")", "error", "{", "o", ".", "StartAt", "=", "sp", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// StartAt sets the desired start position for the message stream.
[ "StartAt", "sets", "the", "desired", "start", "position", "for", "the", "message", "stream", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/sub.go#L156-L161
train
nats-io/go-nats-streaming
sub.go
StartAtSequence
func StartAtSequence(seq uint64) SubscriptionOption { return func(o *SubscriptionOptions) error { o.StartAt = pb.StartPosition_SequenceStart o.StartSequence = seq return nil } }
go
func StartAtSequence(seq uint64) SubscriptionOption { return func(o *SubscriptionOptions) error { o.StartAt = pb.StartPosition_SequenceStart o.StartSequence = seq return nil } }
[ "func", "StartAtSequence", "(", "seq", "uint64", ")", "SubscriptionOption", "{", "return", "func", "(", "o", "*", "SubscriptionOptions", ")", "error", "{", "o", ".", "StartAt", "=", "pb", ".", "StartPosition_SequenceStart", "\n", "o", ".", "StartSequence", "="...
// StartAtSequence sets the desired start sequence position and state.
[ "StartAtSequence", "sets", "the", "desired", "start", "sequence", "position", "and", "state", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/sub.go#L164-L170
train
nats-io/go-nats-streaming
sub.go
StartAtTime
func StartAtTime(start time.Time) SubscriptionOption { return func(o *SubscriptionOptions) error { o.StartAt = pb.StartPosition_TimeDeltaStart o.StartTime = start return nil } }
go
func StartAtTime(start time.Time) SubscriptionOption { return func(o *SubscriptionOptions) error { o.StartAt = pb.StartPosition_TimeDeltaStart o.StartTime = start return nil } }
[ "func", "StartAtTime", "(", "start", "time", ".", "Time", ")", "SubscriptionOption", "{", "return", "func", "(", "o", "*", "SubscriptionOptions", ")", "error", "{", "o", ".", "StartAt", "=", "pb", ".", "StartPosition_TimeDeltaStart", "\n", "o", ".", "StartTi...
// StartAtTime sets the desired start time position and state.
[ "StartAtTime", "sets", "the", "desired", "start", "time", "position", "and", "state", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/sub.go#L173-L179
train
nats-io/go-nats-streaming
sub.go
StartAtTimeDelta
func StartAtTimeDelta(ago time.Duration) SubscriptionOption { return func(o *SubscriptionOptions) error { o.StartAt = pb.StartPosition_TimeDeltaStart o.StartTime = time.Now().Add(-ago) return nil } }
go
func StartAtTimeDelta(ago time.Duration) SubscriptionOption { return func(o *SubscriptionOptions) error { o.StartAt = pb.StartPosition_TimeDeltaStart o.StartTime = time.Now().Add(-ago) return nil } }
[ "func", "StartAtTimeDelta", "(", "ago", "time", ".", "Duration", ")", "SubscriptionOption", "{", "return", "func", "(", "o", "*", "SubscriptionOptions", ")", "error", "{", "o", ".", "StartAt", "=", "pb", ".", "StartPosition_TimeDeltaStart", "\n", "o", ".", "...
// StartAtTimeDelta sets the desired start time position and state using the delta.
[ "StartAtTimeDelta", "sets", "the", "desired", "start", "time", "position", "and", "state", "using", "the", "delta", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/sub.go#L182-L188
train
nats-io/go-nats-streaming
sub.go
StartWithLastReceived
func StartWithLastReceived() SubscriptionOption { return func(o *SubscriptionOptions) error { o.StartAt = pb.StartPosition_LastReceived return nil } }
go
func StartWithLastReceived() SubscriptionOption { return func(o *SubscriptionOptions) error { o.StartAt = pb.StartPosition_LastReceived return nil } }
[ "func", "StartWithLastReceived", "(", ")", "SubscriptionOption", "{", "return", "func", "(", "o", "*", "SubscriptionOptions", ")", "error", "{", "o", ".", "StartAt", "=", "pb", ".", "StartPosition_LastReceived", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// StartWithLastReceived is a helper function to set start position to last received.
[ "StartWithLastReceived", "is", "a", "helper", "function", "to", "set", "start", "position", "to", "last", "received", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/sub.go#L191-L196
train
nats-io/go-nats-streaming
sub.go
DeliverAllAvailable
func DeliverAllAvailable() SubscriptionOption { return func(o *SubscriptionOptions) error { o.StartAt = pb.StartPosition_First return nil } }
go
func DeliverAllAvailable() SubscriptionOption { return func(o *SubscriptionOptions) error { o.StartAt = pb.StartPosition_First return nil } }
[ "func", "DeliverAllAvailable", "(", ")", "SubscriptionOption", "{", "return", "func", "(", "o", "*", "SubscriptionOptions", ")", "error", "{", "o", ".", "StartAt", "=", "pb", ".", "StartPosition_First", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// DeliverAllAvailable will deliver all messages available.
[ "DeliverAllAvailable", "will", "deliver", "all", "messages", "available", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/sub.go#L199-L204
train
nats-io/go-nats-streaming
sub.go
DurableName
func DurableName(name string) SubscriptionOption { return func(o *SubscriptionOptions) error { o.DurableName = name return nil } }
go
func DurableName(name string) SubscriptionOption { return func(o *SubscriptionOptions) error { o.DurableName = name return nil } }
[ "func", "DurableName", "(", "name", "string", ")", "SubscriptionOption", "{", "return", "func", "(", "o", "*", "SubscriptionOptions", ")", "error", "{", "o", ".", "DurableName", "=", "name", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// DurableName sets the DurableName for the subscriber.
[ "DurableName", "sets", "the", "DurableName", "for", "the", "subscriber", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/sub.go#L215-L220
train
nats-io/go-nats-streaming
sub.go
Subscribe
func (sc *conn) Subscribe(subject string, cb MsgHandler, options ...SubscriptionOption) (Subscription, error) { return sc.subscribe(subject, "", cb, options...) }
go
func (sc *conn) Subscribe(subject string, cb MsgHandler, options ...SubscriptionOption) (Subscription, error) { return sc.subscribe(subject, "", cb, options...) }
[ "func", "(", "sc", "*", "conn", ")", "Subscribe", "(", "subject", "string", ",", "cb", "MsgHandler", ",", "options", "...", "SubscriptionOption", ")", "(", "Subscription", ",", "error", ")", "{", "return", "sc", ".", "subscribe", "(", "subject", ",", "\"...
// Subscribe will perform a subscription with the given options to the NATS Streaming cluster.
[ "Subscribe", "will", "perform", "a", "subscription", "with", "the", "given", "options", "to", "the", "NATS", "Streaming", "cluster", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/sub.go#L223-L225
train
nats-io/go-nats-streaming
sub.go
QueueSubscribe
func (sc *conn) QueueSubscribe(subject, qgroup string, cb MsgHandler, options ...SubscriptionOption) (Subscription, error) { return sc.subscribe(subject, qgroup, cb, options...) }
go
func (sc *conn) QueueSubscribe(subject, qgroup string, cb MsgHandler, options ...SubscriptionOption) (Subscription, error) { return sc.subscribe(subject, qgroup, cb, options...) }
[ "func", "(", "sc", "*", "conn", ")", "QueueSubscribe", "(", "subject", ",", "qgroup", "string", ",", "cb", "MsgHandler", ",", "options", "...", "SubscriptionOption", ")", "(", "Subscription", ",", "error", ")", "{", "return", "sc", ".", "subscribe", "(", ...
// QueueSubscribe will perform a queue subscription with the given options to the NATS Streaming cluster.
[ "QueueSubscribe", "will", "perform", "a", "queue", "subscription", "with", "the", "given", "options", "to", "the", "NATS", "Streaming", "cluster", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/sub.go#L228-L230
train
nats-io/go-nats-streaming
sub.go
subscribe
func (sc *conn) subscribe(subject, qgroup string, cb MsgHandler, options ...SubscriptionOption) (Subscription, error) { sub := &subscription{subject: subject, qgroup: qgroup, inbox: nats.NewInbox(), cb: cb, sc: sc, opts: DefaultSubscriptionOptions} for _, opt := range options { if err := opt(&sub.opts); err != nil { return nil, err } } sc.Lock() if sc.nc == nil { sc.Unlock() return nil, ErrConnectionClosed } // Register subscription. sc.subMap[sub.inbox] = sub nc := sc.nc sc.Unlock() // Hold lock throughout. sub.Lock() defer sub.Unlock() // Listen for actual messages. nsub, err := nc.Subscribe(sub.inbox, sc.processMsg) if err != nil { return nil, err } sub.inboxSub = nsub // Create a subscription request // FIXME(dlc) add others. sr := &pb.SubscriptionRequest{ ClientID: sc.clientID, Subject: subject, QGroup: qgroup, Inbox: sub.inbox, MaxInFlight: int32(sub.opts.MaxInflight), AckWaitInSecs: int32(sub.opts.AckWait / time.Second), StartPosition: sub.opts.StartAt, DurableName: sub.opts.DurableName, } // Conditionals switch sr.StartPosition { case pb.StartPosition_TimeDeltaStart: sr.StartTimeDelta = time.Now().UnixNano() - sub.opts.StartTime.UnixNano() case pb.StartPosition_SequenceStart: sr.StartSequence = sub.opts.StartSequence } b, _ := sr.Marshal() reply, err := nc.Request(sc.subRequests, b, sc.opts.ConnectTimeout) if err != nil { sub.inboxSub.Unsubscribe() if err == nats.ErrTimeout { err = ErrSubReqTimeout } return nil, err } r := &pb.SubscriptionResponse{} if err := r.Unmarshal(reply.Data); err != nil { sub.inboxSub.Unsubscribe() return nil, err } if r.Error != "" { sub.inboxSub.Unsubscribe() return nil, errors.New(r.Error) } sub.ackInbox = r.AckInbox return sub, nil }
go
func (sc *conn) subscribe(subject, qgroup string, cb MsgHandler, options ...SubscriptionOption) (Subscription, error) { sub := &subscription{subject: subject, qgroup: qgroup, inbox: nats.NewInbox(), cb: cb, sc: sc, opts: DefaultSubscriptionOptions} for _, opt := range options { if err := opt(&sub.opts); err != nil { return nil, err } } sc.Lock() if sc.nc == nil { sc.Unlock() return nil, ErrConnectionClosed } // Register subscription. sc.subMap[sub.inbox] = sub nc := sc.nc sc.Unlock() // Hold lock throughout. sub.Lock() defer sub.Unlock() // Listen for actual messages. nsub, err := nc.Subscribe(sub.inbox, sc.processMsg) if err != nil { return nil, err } sub.inboxSub = nsub // Create a subscription request // FIXME(dlc) add others. sr := &pb.SubscriptionRequest{ ClientID: sc.clientID, Subject: subject, QGroup: qgroup, Inbox: sub.inbox, MaxInFlight: int32(sub.opts.MaxInflight), AckWaitInSecs: int32(sub.opts.AckWait / time.Second), StartPosition: sub.opts.StartAt, DurableName: sub.opts.DurableName, } // Conditionals switch sr.StartPosition { case pb.StartPosition_TimeDeltaStart: sr.StartTimeDelta = time.Now().UnixNano() - sub.opts.StartTime.UnixNano() case pb.StartPosition_SequenceStart: sr.StartSequence = sub.opts.StartSequence } b, _ := sr.Marshal() reply, err := nc.Request(sc.subRequests, b, sc.opts.ConnectTimeout) if err != nil { sub.inboxSub.Unsubscribe() if err == nats.ErrTimeout { err = ErrSubReqTimeout } return nil, err } r := &pb.SubscriptionResponse{} if err := r.Unmarshal(reply.Data); err != nil { sub.inboxSub.Unsubscribe() return nil, err } if r.Error != "" { sub.inboxSub.Unsubscribe() return nil, errors.New(r.Error) } sub.ackInbox = r.AckInbox return sub, nil }
[ "func", "(", "sc", "*", "conn", ")", "subscribe", "(", "subject", ",", "qgroup", "string", ",", "cb", "MsgHandler", ",", "options", "...", "SubscriptionOption", ")", "(", "Subscription", ",", "error", ")", "{", "sub", ":=", "&", "subscription", "{", "sub...
// subscribe will perform a subscription with the given options to the NATS Streaming cluster.
[ "subscribe", "will", "perform", "a", "subscription", "with", "the", "given", "options", "to", "the", "NATS", "Streaming", "cluster", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/sub.go#L233-L304
train
nats-io/go-nats-streaming
sub.go
closeOrUnsubscribe
func (sub *subscription) closeOrUnsubscribe(doClose bool) error { sub.Lock() sc := sub.sc if sc == nil { // Already closed. sub.Unlock() return ErrBadSubscription } sub.sc = nil sub.inboxSub.Unsubscribe() sub.inboxSub = nil sub.Unlock() sc.Lock() if sc.nc == nil { sc.Unlock() return ErrConnectionClosed } delete(sc.subMap, sub.inbox) reqSubject := sc.unsubRequests if doClose { reqSubject = sc.subCloseRequests if reqSubject == "" { sc.Unlock() return ErrNoServerSupport } } // Snapshot connection to avoid data race, since the connection may be // closing while we try to send the request nc := sc.nc sc.Unlock() usr := &pb.UnsubscribeRequest{ ClientID: sc.clientID, Subject: sub.subject, Inbox: sub.ackInbox, } b, _ := usr.Marshal() reply, err := nc.Request(reqSubject, b, sc.opts.ConnectTimeout) if err != nil { if err == nats.ErrTimeout { if doClose { return ErrCloseReqTimeout } return ErrUnsubReqTimeout } return err } r := &pb.SubscriptionResponse{} if err := r.Unmarshal(reply.Data); err != nil { return err } if r.Error != "" { return errors.New(r.Error) } return nil }
go
func (sub *subscription) closeOrUnsubscribe(doClose bool) error { sub.Lock() sc := sub.sc if sc == nil { // Already closed. sub.Unlock() return ErrBadSubscription } sub.sc = nil sub.inboxSub.Unsubscribe() sub.inboxSub = nil sub.Unlock() sc.Lock() if sc.nc == nil { sc.Unlock() return ErrConnectionClosed } delete(sc.subMap, sub.inbox) reqSubject := sc.unsubRequests if doClose { reqSubject = sc.subCloseRequests if reqSubject == "" { sc.Unlock() return ErrNoServerSupport } } // Snapshot connection to avoid data race, since the connection may be // closing while we try to send the request nc := sc.nc sc.Unlock() usr := &pb.UnsubscribeRequest{ ClientID: sc.clientID, Subject: sub.subject, Inbox: sub.ackInbox, } b, _ := usr.Marshal() reply, err := nc.Request(reqSubject, b, sc.opts.ConnectTimeout) if err != nil { if err == nats.ErrTimeout { if doClose { return ErrCloseReqTimeout } return ErrUnsubReqTimeout } return err } r := &pb.SubscriptionResponse{} if err := r.Unmarshal(reply.Data); err != nil { return err } if r.Error != "" { return errors.New(r.Error) } return nil }
[ "func", "(", "sub", "*", "subscription", ")", "closeOrUnsubscribe", "(", "doClose", "bool", ")", "error", "{", "sub", ".", "Lock", "(", ")", "\n", "sc", ":=", "sub", ".", "sc", "\n", "if", "sc", "==", "nil", "{", "// Already closed.", "sub", ".", "Un...
// closeOrUnsubscribe performs either close or unsubsribe based on // given boolean.
[ "closeOrUnsubscribe", "performs", "either", "close", "or", "unsubsribe", "based", "on", "given", "boolean", "." ]
3e2ff0719c7a6219b4e791e19c782de98c701f4a
https://github.com/nats-io/go-nats-streaming/blob/3e2ff0719c7a6219b4e791e19c782de98c701f4a/sub.go#L396-L455
train
twpayne/go-geom
xyz/xyz.go
Distance
func Distance(point1, point2 geom.Coord) float64 { // default to 2D distance if either Z is not set if math.IsNaN(point1[2]) || math.IsNaN(point2[2]) { return xy.Distance(point1, point2) } dx := point1[0] - point2[0] dy := point1[1] - point2[1] dz := point1[2] - point2[2] return math.Sqrt(dx*dx + dy*dy + dz*dz) }
go
func Distance(point1, point2 geom.Coord) float64 { // default to 2D distance if either Z is not set if math.IsNaN(point1[2]) || math.IsNaN(point2[2]) { return xy.Distance(point1, point2) } dx := point1[0] - point2[0] dy := point1[1] - point2[1] dz := point1[2] - point2[2] return math.Sqrt(dx*dx + dy*dy + dz*dz) }
[ "func", "Distance", "(", "point1", ",", "point2", "geom", ".", "Coord", ")", "float64", "{", "// default to 2D distance if either Z is not set", "if", "math", ".", "IsNaN", "(", "point1", "[", "2", "]", ")", "||", "math", ".", "IsNaN", "(", "point2", "[", ...
// Distance calculates the distance between the two coordinates in 3d space.
[ "Distance", "calculates", "the", "distance", "between", "the", "two", "coordinates", "in", "3d", "space", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xyz/xyz.go#L14-L24
train
twpayne/go-geom
xyz/xyz.go
DistancePointToLine
func DistancePointToLine(point, lineStart, lineEnd geom.Coord) float64 { // if start = end, then just compute distance to one of the endpoints if Equals(lineStart, lineEnd) { return Distance(point, lineStart) } // otherwise use comp.graphics.algorithms Frequently Asked Questions method /* * (1) r = AC dot AB * --------- * ||AB||^2 * * r has the following meaning: * r=0 P = A * r=1 P = B * r<0 P is on the backward extension of AB * r>1 P is on the forward extension of AB * 0<r<1 P is interior to AB */ len2 := (lineEnd[0]-lineStart[0])*(lineEnd[0]-lineStart[0]) + (lineEnd[1]-lineStart[1])*(lineEnd[1]-lineStart[1]) + (lineEnd[2]-lineStart[2])*(lineEnd[2]-lineStart[2]) if math.IsNaN(len2) { panic("Ordinates must not be NaN") } r := ((point[0]-lineStart[0])*(lineEnd[0]-lineStart[0]) + (point[1]-lineStart[1])*(lineEnd[1]-lineStart[1]) + (point[2]-lineStart[2])*(lineEnd[2]-lineStart[2])) / len2 if r <= 0.0 { return Distance(point, lineStart) } if r >= 1.0 { return Distance(point, lineEnd) } // compute closest point q on line segment qx := lineStart[0] + r*(lineEnd[0]-lineStart[0]) qy := lineStart[1] + r*(lineEnd[1]-lineStart[1]) qz := lineStart[2] + r*(lineEnd[2]-lineStart[2]) // result is distance from p to q dx := point[0] - qx dy := point[1] - qy dz := point[2] - qz return math.Sqrt(dx*dx + dy*dy + dz*dz) }
go
func DistancePointToLine(point, lineStart, lineEnd geom.Coord) float64 { // if start = end, then just compute distance to one of the endpoints if Equals(lineStart, lineEnd) { return Distance(point, lineStart) } // otherwise use comp.graphics.algorithms Frequently Asked Questions method /* * (1) r = AC dot AB * --------- * ||AB||^2 * * r has the following meaning: * r=0 P = A * r=1 P = B * r<0 P is on the backward extension of AB * r>1 P is on the forward extension of AB * 0<r<1 P is interior to AB */ len2 := (lineEnd[0]-lineStart[0])*(lineEnd[0]-lineStart[0]) + (lineEnd[1]-lineStart[1])*(lineEnd[1]-lineStart[1]) + (lineEnd[2]-lineStart[2])*(lineEnd[2]-lineStart[2]) if math.IsNaN(len2) { panic("Ordinates must not be NaN") } r := ((point[0]-lineStart[0])*(lineEnd[0]-lineStart[0]) + (point[1]-lineStart[1])*(lineEnd[1]-lineStart[1]) + (point[2]-lineStart[2])*(lineEnd[2]-lineStart[2])) / len2 if r <= 0.0 { return Distance(point, lineStart) } if r >= 1.0 { return Distance(point, lineEnd) } // compute closest point q on line segment qx := lineStart[0] + r*(lineEnd[0]-lineStart[0]) qy := lineStart[1] + r*(lineEnd[1]-lineStart[1]) qz := lineStart[2] + r*(lineEnd[2]-lineStart[2]) // result is distance from p to q dx := point[0] - qx dy := point[1] - qy dz := point[2] - qz return math.Sqrt(dx*dx + dy*dy + dz*dz) }
[ "func", "DistancePointToLine", "(", "point", ",", "lineStart", ",", "lineEnd", "geom", ".", "Coord", ")", "float64", "{", "// if start = end, then just compute distance to one of the endpoints", "if", "Equals", "(", "lineStart", ",", "lineEnd", ")", "{", "return", "Di...
// DistancePointToLine calculates the distance from point to a point on the line
[ "DistancePointToLine", "calculates", "the", "distance", "from", "point", "to", "a", "point", "on", "the", "line" ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xyz/xyz.go#L27-L69
train
twpayne/go-geom
xyz/xyz.go
Equals
func Equals(point1, other geom.Coord) bool { return (point1[0] == other[0]) && (point1[1] == other[1]) && ((point1[2] == other[2]) || (math.IsNaN(point1[2]) && math.IsNaN(other[2]))) }
go
func Equals(point1, other geom.Coord) bool { return (point1[0] == other[0]) && (point1[1] == other[1]) && ((point1[2] == other[2]) || (math.IsNaN(point1[2]) && math.IsNaN(other[2]))) }
[ "func", "Equals", "(", "point1", ",", "other", "geom", ".", "Coord", ")", "bool", "{", "return", "(", "point1", "[", "0", "]", "==", "other", "[", "0", "]", ")", "&&", "(", "point1", "[", "1", "]", "==", "other", "[", "1", "]", ")", "&&", "("...
// Equals determines if the two coordinates have equal in 3d space
[ "Equals", "determines", "if", "the", "two", "coordinates", "have", "equal", "in", "3d", "space" ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xyz/xyz.go#L72-L76
train
twpayne/go-geom
xyz/xyz.go
DistanceLineToLine
func DistanceLineToLine(line1Start, line1End, line2Start, line2End geom.Coord) float64 { /** * This calculation is susceptible to roundoff errors when * passed large ordinate values. * It may be possible to improve this by using {@link DD} arithmetic. */ if Equals(line1Start, line1End) { return DistancePointToLine(line1Start, line2Start, line2End) } if Equals(line2Start, line1End) { return DistancePointToLine(line2Start, line1Start, line1End) } /** * Algorithm derived from http://softsurfer.com/Archive/algorithm_0106/algorithm_0106.htm */ a := VectorDot(line1Start, line1End, line1Start, line1End) b := VectorDot(line1Start, line1End, line2Start, line2End) c := VectorDot(line2Start, line2End, line2Start, line2End) d := VectorDot(line1Start, line1End, line2Start, line1Start) e := VectorDot(line2Start, line2End, line2Start, line1Start) denom := a*c - b*b if math.IsNaN(denom) { panic("Ordinates must not be NaN") } var s, t float64 if denom <= 0.0 { /** * The lines are parallel. * In this case solve for the parameters s and t by assuming s is 0. */ s = 0 // choose largest denominator for optimal numeric conditioning if b > c { t = d / b } else { t = e / c } } else { s = (b*e - c*d) / denom t = (a*e - b*d) / denom } switch { case s < 0: return DistancePointToLine(line1Start, line2Start, line2End) case s > 1: return DistancePointToLine(line1End, line2Start, line2End) case t < 0: return DistancePointToLine(line2Start, line1Start, line1End) case t > 1: return DistancePointToLine(line2End, line1Start, line1End) } /** * The closest points are in interiors of segments, * so compute them directly */ x1 := line1Start[0] + s*(line1End[0]-line1Start[0]) y1 := line1Start[1] + s*(line1End[1]-line1Start[1]) z1 := line1Start[2] + s*(line1End[2]-line1Start[2]) x2 := line2Start[0] + t*(line2End[0]-line2Start[0]) y2 := line2Start[1] + t*(line2End[1]-line2Start[1]) z2 := line2Start[2] + t*(line2End[2]-line2Start[2]) // length (p1-p2) return Distance(geom.Coord{x1, y1, z1}, geom.Coord{x2, y2, z2}) }
go
func DistanceLineToLine(line1Start, line1End, line2Start, line2End geom.Coord) float64 { /** * This calculation is susceptible to roundoff errors when * passed large ordinate values. * It may be possible to improve this by using {@link DD} arithmetic. */ if Equals(line1Start, line1End) { return DistancePointToLine(line1Start, line2Start, line2End) } if Equals(line2Start, line1End) { return DistancePointToLine(line2Start, line1Start, line1End) } /** * Algorithm derived from http://softsurfer.com/Archive/algorithm_0106/algorithm_0106.htm */ a := VectorDot(line1Start, line1End, line1Start, line1End) b := VectorDot(line1Start, line1End, line2Start, line2End) c := VectorDot(line2Start, line2End, line2Start, line2End) d := VectorDot(line1Start, line1End, line2Start, line1Start) e := VectorDot(line2Start, line2End, line2Start, line1Start) denom := a*c - b*b if math.IsNaN(denom) { panic("Ordinates must not be NaN") } var s, t float64 if denom <= 0.0 { /** * The lines are parallel. * In this case solve for the parameters s and t by assuming s is 0. */ s = 0 // choose largest denominator for optimal numeric conditioning if b > c { t = d / b } else { t = e / c } } else { s = (b*e - c*d) / denom t = (a*e - b*d) / denom } switch { case s < 0: return DistancePointToLine(line1Start, line2Start, line2End) case s > 1: return DistancePointToLine(line1End, line2Start, line2End) case t < 0: return DistancePointToLine(line2Start, line1Start, line1End) case t > 1: return DistancePointToLine(line2End, line1Start, line1End) } /** * The closest points are in interiors of segments, * so compute them directly */ x1 := line1Start[0] + s*(line1End[0]-line1Start[0]) y1 := line1Start[1] + s*(line1End[1]-line1Start[1]) z1 := line1Start[2] + s*(line1End[2]-line1Start[2]) x2 := line2Start[0] + t*(line2End[0]-line2Start[0]) y2 := line2Start[1] + t*(line2End[1]-line2Start[1]) z2 := line2Start[2] + t*(line2End[2]-line2Start[2]) // length (p1-p2) return Distance(geom.Coord{x1, y1, z1}, geom.Coord{x2, y2, z2}) }
[ "func", "DistanceLineToLine", "(", "line1Start", ",", "line1End", ",", "line2Start", ",", "line2End", "geom", ".", "Coord", ")", "float64", "{", "/**\n\t * This calculation is susceptible to roundoff errors when\n\t * passed large ordinate values.\n\t * It may be possible to improve ...
// DistanceLineToLine computes the distance between two 3D segments
[ "DistanceLineToLine", "computes", "the", "distance", "between", "two", "3D", "segments" ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xyz/xyz.go#L79-L147
train
twpayne/go-geom
xy/angle.go
AngleBetween
func AngleBetween(tip1, tail, tip2 geom.Coord) float64 { a1 := Angle(tail, tip1) a2 := Angle(tail, tip2) return Diff(a1, a2) }
go
func AngleBetween(tip1, tail, tip2 geom.Coord) float64 { a1 := Angle(tail, tip1) a2 := Angle(tail, tip2) return Diff(a1, a2) }
[ "func", "AngleBetween", "(", "tip1", ",", "tail", ",", "tip2", "geom", ".", "Coord", ")", "float64", "{", "a1", ":=", "Angle", "(", "tail", ",", "tip1", ")", "\n", "a2", ":=", "Angle", "(", "tail", ",", "tip2", ")", "\n\n", "return", "Diff", "(", ...
// AngleBetween calculates the un-oriented smallest angle between two vectors. // The computed angle will be in the range [0, Pi). // // Param tip1 - the tip of one vector // param tail - the tail of each vector // param tip2 - the tip of the other vector
[ "AngleBetween", "calculates", "the", "un", "-", "oriented", "smallest", "angle", "between", "two", "vectors", ".", "The", "computed", "angle", "will", "be", "in", "the", "range", "[", "0", "Pi", ")", ".", "Param", "tip1", "-", "the", "tip", "of", "one", ...
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/angle.go#L62-L67
train
twpayne/go-geom
xy/angle.go
AngleOrientation
func AngleOrientation(ang1, ang2 float64) orientation.Type { crossproduct := math.Sin(ang2 - ang1) switch { case crossproduct > 0: return orientation.CounterClockwise case crossproduct < 0: return orientation.Clockwise default: return orientation.Collinear } }
go
func AngleOrientation(ang1, ang2 float64) orientation.Type { crossproduct := math.Sin(ang2 - ang1) switch { case crossproduct > 0: return orientation.CounterClockwise case crossproduct < 0: return orientation.Clockwise default: return orientation.Collinear } }
[ "func", "AngleOrientation", "(", "ang1", ",", "ang2", "float64", ")", "orientation", ".", "Type", "{", "crossproduct", ":=", "math", ".", "Sin", "(", "ang2", "-", "ang1", ")", "\n\n", "switch", "{", "case", "crossproduct", ">", "0", ":", "return", "orien...
// AngleOrientation returns whether an angle must turn clockwise or counterclockwise // overlap another angle.
[ "AngleOrientation", "returns", "whether", "an", "angle", "must", "turn", "clockwise", "or", "counterclockwise", "overlap", "another", "angle", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/angle.go#L93-L104
train
twpayne/go-geom
xy/angle.go
Normalize
func Normalize(angle float64) float64 { for angle > math.Pi { angle -= piTimes2 } for angle <= -math.Pi { angle += piTimes2 } return angle }
go
func Normalize(angle float64) float64 { for angle > math.Pi { angle -= piTimes2 } for angle <= -math.Pi { angle += piTimes2 } return angle }
[ "func", "Normalize", "(", "angle", "float64", ")", "float64", "{", "for", "angle", ">", "math", ".", "Pi", "{", "angle", "-=", "piTimes2", "\n", "}", "\n", "for", "angle", "<=", "-", "math", ".", "Pi", "{", "angle", "+=", "piTimes2", "\n", "}", "\n...
// Normalize computes the normalized value of an angle, which is the // equivalent angle in the range ( -Pi, Pi ].
[ "Normalize", "computes", "the", "normalized", "value", "of", "an", "angle", "which", "is", "the", "equivalent", "angle", "in", "the", "range", "(", "-", "Pi", "Pi", "]", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/angle.go#L108-L116
train
twpayne/go-geom
geom.go
MIndex
func (l Layout) MIndex() int { switch l { case NoLayout, XY, XYZ: return -1 case XYM: return 2 case XYZM: return 3 default: return 3 } }
go
func (l Layout) MIndex() int { switch l { case NoLayout, XY, XYZ: return -1 case XYM: return 2 case XYZM: return 3 default: return 3 } }
[ "func", "(", "l", "Layout", ")", "MIndex", "(", ")", "int", "{", "switch", "l", "{", "case", "NoLayout", ",", "XY", ",", "XYZ", ":", "return", "-", "1", "\n", "case", "XYM", ":", "return", "2", "\n", "case", "XYZM", ":", "return", "3", "\n", "d...
// MIndex returns the index of the M dimension, or -1 if the l does not have an // M dimension.
[ "MIndex", "returns", "the", "index", "of", "the", "M", "dimension", "or", "-", "1", "if", "the", "l", "does", "not", "have", "an", "M", "dimension", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/geom.go#L135-L146
train
twpayne/go-geom
geom.go
Stride
func (l Layout) Stride() int { switch l { case NoLayout: return 0 case XY: return 2 case XYZ: return 3 case XYM: return 3 case XYZM: return 4 default: return int(l) } }
go
func (l Layout) Stride() int { switch l { case NoLayout: return 0 case XY: return 2 case XYZ: return 3 case XYM: return 3 case XYZM: return 4 default: return int(l) } }
[ "func", "(", "l", "Layout", ")", "Stride", "(", ")", "int", "{", "switch", "l", "{", "case", "NoLayout", ":", "return", "0", "\n", "case", "XY", ":", "return", "2", "\n", "case", "XYZ", ":", "return", "3", "\n", "case", "XYM", ":", "return", "3",...
// Stride returns l's number of dimensions.
[ "Stride", "returns", "l", "s", "number", "of", "dimensions", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/geom.go#L149-L164
train
twpayne/go-geom
geom.go
String
func (l Layout) String() string { switch l { case NoLayout: return "NoLayout" case XY: return "XY" case XYZ: return "XYZ" case XYM: return "XYM" case XYZM: return "XYZM" default: return fmt.Sprintf("Layout(%d)", int(l)) } }
go
func (l Layout) String() string { switch l { case NoLayout: return "NoLayout" case XY: return "XY" case XYZ: return "XYZ" case XYM: return "XYM" case XYZM: return "XYZM" default: return fmt.Sprintf("Layout(%d)", int(l)) } }
[ "func", "(", "l", "Layout", ")", "String", "(", ")", "string", "{", "switch", "l", "{", "case", "NoLayout", ":", "return", "\"", "\"", "\n", "case", "XY", ":", "return", "\"", "\"", "\n", "case", "XYZ", ":", "return", "\"", "\"", "\n", "case", "X...
// String returns a human-readable string representing l.
[ "String", "returns", "a", "human", "-", "readable", "string", "representing", "l", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/geom.go#L167-L182
train
twpayne/go-geom
geom.go
Must
func Must(g T, err error) T { if err != nil { panic(err) } return g }
go
func Must(g T, err error) T { if err != nil { panic(err) } return g }
[ "func", "Must", "(", "g", "T", ",", "err", "error", ")", "T", "{", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "return", "g", "\n", "}" ]
// Must panics if err is not nil, otherwise it returns g.
[ "Must", "panics", "if", "err", "is", "not", "nil", "otherwise", "it", "returns", "g", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/geom.go#L196-L201
train
twpayne/go-geom
xy/lineintersection/line_on_line_intersection.go
NewResult
func NewResult(intersectionType Type, intersection []geom.Coord) Result { return Result{ intersectionType: intersectionType, intersection: intersection, } }
go
func NewResult(intersectionType Type, intersection []geom.Coord) Result { return Result{ intersectionType: intersectionType, intersection: intersection, } }
[ "func", "NewResult", "(", "intersectionType", "Type", ",", "intersection", "[", "]", "geom", ".", "Coord", ")", "Result", "{", "return", "Result", "{", "intersectionType", ":", "intersectionType", ",", "intersection", ":", "intersection", ",", "}", "\n", "}" ]
// NewResult create a new result object
[ "NewResult", "create", "a", "new", "result", "object" ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/lineintersection/line_on_line_intersection.go#L32-L37
train
twpayne/go-geom
xy/internal/numbers.go
IsSameSignAndNonZero
func IsSameSignAndNonZero(a, b float64) bool { if a == 0 || b == 0 { return false } return (a < 0 && b < 0) || (a > 0 && b > 0) }
go
func IsSameSignAndNonZero(a, b float64) bool { if a == 0 || b == 0 { return false } return (a < 0 && b < 0) || (a > 0 && b > 0) }
[ "func", "IsSameSignAndNonZero", "(", "a", ",", "b", "float64", ")", "bool", "{", "if", "a", "==", "0", "||", "b", "==", "0", "{", "return", "false", "\n", "}", "\n", "return", "(", "a", "<", "0", "&&", "b", "<", "0", ")", "||", "(", "a", ">",...
// IsSameSignAndNonZero checks if both a and b are positive or negative.
[ "IsSameSignAndNonZero", "checks", "if", "both", "a", "and", "b", "are", "positive", "or", "negative", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/internal/numbers.go#L4-L9
train
twpayne/go-geom
xy/internal/numbers.go
Min
func Min(v1, v2, v3, v4 float64) float64 { min := v1 if v2 < min { min = v2 } if v3 < min { min = v3 } if v4 < min { min = v4 } return min }
go
func Min(v1, v2, v3, v4 float64) float64 { min := v1 if v2 < min { min = v2 } if v3 < min { min = v3 } if v4 < min { min = v4 } return min }
[ "func", "Min", "(", "v1", ",", "v2", ",", "v3", ",", "v4", "float64", ")", "float64", "{", "min", ":=", "v1", "\n", "if", "v2", "<", "min", "{", "min", "=", "v2", "\n", "}", "\n", "if", "v3", "<", "min", "{", "min", "=", "v3", "\n", "}", ...
// Min finds the minimum of the 4 parameters
[ "Min", "finds", "the", "minimum", "of", "the", "4", "parameters" ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/internal/numbers.go#L12-L24
train
twpayne/go-geom
encoding/wkbhex/wkbhex.go
Encode
func Encode(g geom.T, byteOrder binary.ByteOrder) (string, error) { wkb, err := wkb.Marshal(g, byteOrder) if err != nil { return "", err } return hex.EncodeToString(wkb), nil }
go
func Encode(g geom.T, byteOrder binary.ByteOrder) (string, error) { wkb, err := wkb.Marshal(g, byteOrder) if err != nil { return "", err } return hex.EncodeToString(wkb), nil }
[ "func", "Encode", "(", "g", "geom", ".", "T", ",", "byteOrder", "binary", ".", "ByteOrder", ")", "(", "string", ",", "error", ")", "{", "wkb", ",", "err", ":=", "wkb", ".", "Marshal", "(", "g", ",", "byteOrder", ")", "\n", "if", "err", "!=", "nil...
// Encode encodes an arbitrary geometry to a string.
[ "Encode", "encodes", "an", "arbitrary", "geometry", "to", "a", "string", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/wkbhex/wkbhex.go#L21-L27
train
twpayne/go-geom
encoding/wkbhex/wkbhex.go
Decode
func Decode(s string) (geom.T, error) { data, err := hex.DecodeString(s) if err != nil { return nil, err } return wkb.Unmarshal(data) }
go
func Decode(s string) (geom.T, error) { data, err := hex.DecodeString(s) if err != nil { return nil, err } return wkb.Unmarshal(data) }
[ "func", "Decode", "(", "s", "string", ")", "(", "geom", ".", "T", ",", "error", ")", "{", "data", ",", "err", ":=", "hex", ".", "DecodeString", "(", "s", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", ...
// Decode decodes an arbitrary geometry from a string.
[ "Decode", "decodes", "an", "arbitrary", "geometry", "from", "a", "string", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/wkbhex/wkbhex.go#L30-L36
train
twpayne/go-geom
polygon.go
NewPolygonFlat
func NewPolygonFlat(layout Layout, flatCoords []float64, ends []int) *Polygon { g := new(Polygon) g.layout = layout g.stride = layout.Stride() g.flatCoords = flatCoords g.ends = ends return g }
go
func NewPolygonFlat(layout Layout, flatCoords []float64, ends []int) *Polygon { g := new(Polygon) g.layout = layout g.stride = layout.Stride() g.flatCoords = flatCoords g.ends = ends return g }
[ "func", "NewPolygonFlat", "(", "layout", "Layout", ",", "flatCoords", "[", "]", "float64", ",", "ends", "[", "]", "int", ")", "*", "Polygon", "{", "g", ":=", "new", "(", "Polygon", ")", "\n", "g", ".", "layout", "=", "layout", "\n", "g", ".", "stri...
// NewPolygonFlat returns a new Polygon with the given flat coordinates.
[ "NewPolygonFlat", "returns", "a", "new", "Polygon", "with", "the", "given", "flat", "coordinates", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/polygon.go#L16-L23
train
twpayne/go-geom
polygon.go
Area
func (g *Polygon) Area() float64 { return doubleArea2(g.flatCoords, 0, g.ends, g.stride) / 2 }
go
func (g *Polygon) Area() float64 { return doubleArea2(g.flatCoords, 0, g.ends, g.stride) / 2 }
[ "func", "(", "g", "*", "Polygon", ")", "Area", "(", ")", "float64", "{", "return", "doubleArea2", "(", "g", ".", "flatCoords", ",", "0", ",", "g", ".", "ends", ",", "g", ".", "stride", ")", "/", "2", "\n", "}" ]
// Area returns the area.
[ "Area", "returns", "the", "area", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/polygon.go#L26-L28
train
twpayne/go-geom
polygon.go
Length
func (g *Polygon) Length() float64 { return length2(g.flatCoords, 0, g.ends, g.stride) }
go
func (g *Polygon) Length() float64 { return length2(g.flatCoords, 0, g.ends, g.stride) }
[ "func", "(", "g", "*", "Polygon", ")", "Length", "(", ")", "float64", "{", "return", "length2", "(", "g", ".", "flatCoords", ",", "0", ",", "g", ".", "ends", ",", "g", ".", "stride", ")", "\n", "}" ]
// Length returns the perimter.
[ "Length", "returns", "the", "perimter", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/polygon.go#L41-L43
train
twpayne/go-geom
polygon.go
LinearRing
func (g *Polygon) LinearRing(i int) *LinearRing { offset := 0 if i > 0 { offset = g.ends[i-1] } return NewLinearRingFlat(g.layout, g.flatCoords[offset:g.ends[i]]) }
go
func (g *Polygon) LinearRing(i int) *LinearRing { offset := 0 if i > 0 { offset = g.ends[i-1] } return NewLinearRingFlat(g.layout, g.flatCoords[offset:g.ends[i]]) }
[ "func", "(", "g", "*", "Polygon", ")", "LinearRing", "(", "i", "int", ")", "*", "LinearRing", "{", "offset", ":=", "0", "\n", "if", "i", ">", "0", "{", "offset", "=", "g", ".", "ends", "[", "i", "-", "1", "]", "\n", "}", "\n", "return", "NewL...
// LinearRing returns the ith LinearRing.
[ "LinearRing", "returns", "the", "ith", "LinearRing", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/polygon.go#L46-L52
train
twpayne/go-geom
polygon.go
Push
func (g *Polygon) Push(lr *LinearRing) error { if lr.layout != g.layout { return ErrLayoutMismatch{Got: lr.layout, Want: g.layout} } g.flatCoords = append(g.flatCoords, lr.flatCoords...) g.ends = append(g.ends, len(g.flatCoords)) return nil }
go
func (g *Polygon) Push(lr *LinearRing) error { if lr.layout != g.layout { return ErrLayoutMismatch{Got: lr.layout, Want: g.layout} } g.flatCoords = append(g.flatCoords, lr.flatCoords...) g.ends = append(g.ends, len(g.flatCoords)) return nil }
[ "func", "(", "g", "*", "Polygon", ")", "Push", "(", "lr", "*", "LinearRing", ")", "error", "{", "if", "lr", ".", "layout", "!=", "g", ".", "layout", "{", "return", "ErrLayoutMismatch", "{", "Got", ":", "lr", ".", "layout", ",", "Want", ":", "g", ...
// Push appends a LinearRing.
[ "Push", "appends", "a", "LinearRing", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/polygon.go#L66-L73
train
twpayne/go-geom
encoding/wkt/wkt.go
Marshal
func Marshal(g geom.T) (string, error) { b := &bytes.Buffer{} if err := write(b, g); err != nil { return "", err } return b.String(), nil }
go
func Marshal(g geom.T) (string, error) { b := &bytes.Buffer{} if err := write(b, g); err != nil { return "", err } return b.String(), nil }
[ "func", "Marshal", "(", "g", "geom", ".", "T", ")", "(", "string", ",", "error", ")", "{", "b", ":=", "&", "bytes", ".", "Buffer", "{", "}", "\n", "if", "err", ":=", "write", "(", "b", ",", "g", ")", ";", "err", "!=", "nil", "{", "return", ...
// Marshal marshals an arbitrary geometry.
[ "Marshal", "marshals", "an", "arbitrary", "geometry", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/wkt/wkt.go#L11-L17
train
twpayne/go-geom
encoding/igc/decode.go
parseH
func (p *parser) parseH(line string) error { m := hRegexp.FindStringSubmatch(line) if m == nil { return fmt.Errorf("invalid H record") } header := Header{ Source: m[1], Key: m[2], KeyExtra: strings.TrimSuffix(m[3], ":"), Value: m[4], } p.headers = append(p.headers, header) if header.Key == "DTE" { if len(header.Value) < 6 { return fmt.Errorf("H DTE value too short: %d, want >=6", len(header.Value)) } day, err := parseDecInRange(header.Value, 0, 2, 1, 31+1) if err != nil { return err } month, err := parseDecInRange(header.Value, 2, 4, 1, 12+1) if err != nil { return err } year, err := parseDec(header.Value, 4, 6) if err != nil { return err } p.day = day p.month = month if year < 70 { p.year = 2000 + year } else { p.year = 1970 + year } } return nil }
go
func (p *parser) parseH(line string) error { m := hRegexp.FindStringSubmatch(line) if m == nil { return fmt.Errorf("invalid H record") } header := Header{ Source: m[1], Key: m[2], KeyExtra: strings.TrimSuffix(m[3], ":"), Value: m[4], } p.headers = append(p.headers, header) if header.Key == "DTE" { if len(header.Value) < 6 { return fmt.Errorf("H DTE value too short: %d, want >=6", len(header.Value)) } day, err := parseDecInRange(header.Value, 0, 2, 1, 31+1) if err != nil { return err } month, err := parseDecInRange(header.Value, 2, 4, 1, 12+1) if err != nil { return err } year, err := parseDec(header.Value, 4, 6) if err != nil { return err } p.day = day p.month = month if year < 70 { p.year = 2000 + year } else { p.year = 1970 + year } } return nil }
[ "func", "(", "p", "*", "parser", ")", "parseH", "(", "line", "string", ")", "error", "{", "m", ":=", "hRegexp", ".", "FindStringSubmatch", "(", "line", ")", "\n", "if", "m", "==", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", ...
// parseB parses an H record from line and updates the state of p.
[ "parseB", "parses", "an", "H", "record", "from", "line", "and", "updates", "the", "state", "of", "p", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/igc/decode.go#L203-L240
train
twpayne/go-geom
encoding/igc/decode.go
parseI
func (p *parser) parseI(line string) error { var err error var n int if len(line) < 3 { return fmt.Errorf("I record too short: %d, want >=3", len(line)) } if n, err = parseDec(line, 1, 3); err != nil { return err } if len(line) < 7*n+3 { return fmt.Errorf("invalid I record length: %d, want %d", len(line), 7*n+3) } for i := 0; i < n; i++ { var start, stop int if start, err = parseDec(line, 7*i+3, 7*i+5); err != nil { return err } if stop, err = parseDec(line, 7*i+5, 7*i+7); err != nil { return err } if start != p.bRecordLen+1 || stop < start { return fmt.Errorf("I record index out-of-range: %d-%d", start, stop-1) } p.bRecordLen = stop switch line[7*i+7 : 7*i+10] { case "LAD": p.ladStart, p.ladStop = start-1, stop case "LOD": p.lodStart, p.lodStop = start-1, stop case "TDS": p.tdsStart, p.tdsStop = start-1, stop } } return nil }
go
func (p *parser) parseI(line string) error { var err error var n int if len(line) < 3 { return fmt.Errorf("I record too short: %d, want >=3", len(line)) } if n, err = parseDec(line, 1, 3); err != nil { return err } if len(line) < 7*n+3 { return fmt.Errorf("invalid I record length: %d, want %d", len(line), 7*n+3) } for i := 0; i < n; i++ { var start, stop int if start, err = parseDec(line, 7*i+3, 7*i+5); err != nil { return err } if stop, err = parseDec(line, 7*i+5, 7*i+7); err != nil { return err } if start != p.bRecordLen+1 || stop < start { return fmt.Errorf("I record index out-of-range: %d-%d", start, stop-1) } p.bRecordLen = stop switch line[7*i+7 : 7*i+10] { case "LAD": p.ladStart, p.ladStop = start-1, stop case "LOD": p.lodStart, p.lodStop = start-1, stop case "TDS": p.tdsStart, p.tdsStop = start-1, stop } } return nil }
[ "func", "(", "p", "*", "parser", ")", "parseI", "(", "line", "string", ")", "error", "{", "var", "err", "error", "\n", "var", "n", "int", "\n", "if", "len", "(", "line", ")", "<", "3", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", ...
// parseB parses an I record from line and updates the state of p.
[ "parseB", "parses", "an", "I", "record", "from", "line", "and", "updates", "the", "state", "of", "p", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/igc/decode.go#L243-L277
train
twpayne/go-geom
encoding/igc/decode.go
parseLine
func (p *parser) parseLine(line string) error { switch line[0] { case 'B': return p.parseB(line) case 'H': return p.parseH(line) case 'I': return p.parseI(line) default: return nil } }
go
func (p *parser) parseLine(line string) error { switch line[0] { case 'B': return p.parseB(line) case 'H': return p.parseH(line) case 'I': return p.parseI(line) default: return nil } }
[ "func", "(", "p", "*", "parser", ")", "parseLine", "(", "line", "string", ")", "error", "{", "switch", "line", "[", "0", "]", "{", "case", "'B'", ":", "return", "p", ".", "parseB", "(", "line", ")", "\n", "case", "'H'", ":", "return", "p", ".", ...
// parseLine parses a single record from line and updates the state of p.
[ "parseLine", "parses", "a", "single", "record", "from", "line", "and", "updates", "the", "state", "of", "p", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/igc/decode.go#L280-L291
train
twpayne/go-geom
encoding/igc/decode.go
doParse
func doParse(r io.Reader) (*parser, Errors) { var errors Errors p := newParser() s := bufio.NewScanner(r) foundA := false leadingNoise := false for lineno := 1; s.Scan(); lineno++ { line := strings.TrimSuffix(s.Text(), "\r") switch { case len(line) == 0: case foundA: if err := p.parseLine(line); err != nil { errors = append(errors, fmt.Errorf("line %d: %q: %v", lineno, line, err)) } default: if c := line[0]; c == 'A' { foundA = true } else if 'A' <= c && c <= 'Z' { // All records that start with an uppercase character must be valid. leadingNoise = true continue } else if i := strings.IndexRune(line, 'A'); i != -1 { // Strip any leading noise. // Leading Unicode byte order marks and XOFF characters are silently ignored. // The noise must include at least one unprintable character. for j, c := range line[:i] { if !(c == ' ' || ('A' <= c && c <= 'Z')) { foundA = true leadingNoise = j != 0 || (c != '\x13' && c != '\ufeff') break } } } } } if !foundA { errors = append(Errors{errMissingARecord}, errors...) } else if leadingNoise { errors = append(Errors{errInvalidCharactersBeforeARecord}, errors...) } return p, errors }
go
func doParse(r io.Reader) (*parser, Errors) { var errors Errors p := newParser() s := bufio.NewScanner(r) foundA := false leadingNoise := false for lineno := 1; s.Scan(); lineno++ { line := strings.TrimSuffix(s.Text(), "\r") switch { case len(line) == 0: case foundA: if err := p.parseLine(line); err != nil { errors = append(errors, fmt.Errorf("line %d: %q: %v", lineno, line, err)) } default: if c := line[0]; c == 'A' { foundA = true } else if 'A' <= c && c <= 'Z' { // All records that start with an uppercase character must be valid. leadingNoise = true continue } else if i := strings.IndexRune(line, 'A'); i != -1 { // Strip any leading noise. // Leading Unicode byte order marks and XOFF characters are silently ignored. // The noise must include at least one unprintable character. for j, c := range line[:i] { if !(c == ' ' || ('A' <= c && c <= 'Z')) { foundA = true leadingNoise = j != 0 || (c != '\x13' && c != '\ufeff') break } } } } } if !foundA { errors = append(Errors{errMissingARecord}, errors...) } else if leadingNoise { errors = append(Errors{errInvalidCharactersBeforeARecord}, errors...) } return p, errors }
[ "func", "doParse", "(", "r", "io", ".", "Reader", ")", "(", "*", "parser", ",", "Errors", ")", "{", "var", "errors", "Errors", "\n", "p", ":=", "newParser", "(", ")", "\n", "s", ":=", "bufio", ".", "NewScanner", "(", "r", ")", "\n", "foundA", ":=...
// doParse reads r, parsers all the records it finds, updating the state of p.
[ "doParse", "reads", "r", "parsers", "all", "the", "records", "it", "finds", "updating", "the", "state", "of", "p", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/igc/decode.go#L294-L335
train
twpayne/go-geom
encoding/igc/decode.go
Read
func Read(r io.Reader) (*T, error) { p, errors := doParse(r) var err error = errors if len(errors) == 0 { err = nil } return &T{ Headers: p.headers, LineString: geom.NewLineStringFlat(geom.Layout(5), p.coords), }, err }
go
func Read(r io.Reader) (*T, error) { p, errors := doParse(r) var err error = errors if len(errors) == 0 { err = nil } return &T{ Headers: p.headers, LineString: geom.NewLineStringFlat(geom.Layout(5), p.coords), }, err }
[ "func", "Read", "(", "r", "io", ".", "Reader", ")", "(", "*", "T", ",", "error", ")", "{", "p", ",", "errors", ":=", "doParse", "(", "r", ")", "\n", "var", "err", "error", "=", "errors", "\n", "if", "len", "(", "errors", ")", "==", "0", "{", ...
// Read reads a igc.T from r, which should contain IGC records. // // IGC files in the wild are often corrupt, the IGC specification has been // incomplete, and has evolved over time. The parser is consequently very // tolerant of what it accepts and ignores several common errors. Consequently, // the returned T might still contain headers and coordinates, even if the // returned error is non-nil.
[ "Read", "reads", "a", "igc", ".", "T", "from", "r", "which", "should", "contain", "IGC", "records", ".", "IGC", "files", "in", "the", "wild", "are", "often", "corrupt", "the", "IGC", "specification", "has", "been", "incomplete", "and", "has", "evolved", ...
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/igc/decode.go#L344-L354
train
twpayne/go-geom
examples/postgis/main.go
readGeoJSON
func readGeoJSON(db *sql.DB, r io.Reader) error { var waypoint Waypoint if err := json.NewDecoder(r).Decode(&waypoint); err != nil { return err } var geometry geom.T if err := geojson.Unmarshal(waypoint.Geometry, &geometry); err != nil { return err } point, ok := geometry.(*geom.Point) if !ok { return errors.New("geometry is not a point") } _, err := db.Exec(` INSERT INTO waypoints(name, geom) VALUES ($1, $2); `, waypoint.Name, &ewkb.Point{Point: point.SetSRID(4326)}) return err }
go
func readGeoJSON(db *sql.DB, r io.Reader) error { var waypoint Waypoint if err := json.NewDecoder(r).Decode(&waypoint); err != nil { return err } var geometry geom.T if err := geojson.Unmarshal(waypoint.Geometry, &geometry); err != nil { return err } point, ok := geometry.(*geom.Point) if !ok { return errors.New("geometry is not a point") } _, err := db.Exec(` INSERT INTO waypoints(name, geom) VALUES ($1, $2); `, waypoint.Name, &ewkb.Point{Point: point.SetSRID(4326)}) return err }
[ "func", "readGeoJSON", "(", "db", "*", "sql", ".", "DB", ",", "r", "io", ".", "Reader", ")", "error", "{", "var", "waypoint", "Waypoint", "\n", "if", "err", ":=", "json", ".", "NewDecoder", "(", "r", ")", ".", "Decode", "(", "&", "waypoint", ")", ...
// readGeoJSON demonstrates reading data in GeoJSON format and inserting it // into a database in EWKB format.
[ "readGeoJSON", "demonstrates", "reading", "data", "in", "GeoJSON", "format", "and", "inserting", "it", "into", "a", "database", "in", "EWKB", "format", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/examples/postgis/main.go#L83-L100
train
twpayne/go-geom
examples/postgis/main.go
writeGeoJSON
func writeGeoJSON(db *sql.DB, w io.Writer) error { rows, err := db.Query(` SELECT id, name, ST_AsEWKB(geom) FROM waypoints ORDER BY id ASC; `) if err != nil { return err } defer rows.Close() for rows.Next() { var id int var name string var ewkbPoint ewkb.Point if err := rows.Scan(&id, &name, &ewkbPoint); err != nil { return err } geometry, err := geojson.Marshal(ewkbPoint.Point) if err != nil { return err } if err := json.NewEncoder(w).Encode(&Waypoint{ ID: id, Name: name, Geometry: geometry, }); err != nil { return err } } return nil }
go
func writeGeoJSON(db *sql.DB, w io.Writer) error { rows, err := db.Query(` SELECT id, name, ST_AsEWKB(geom) FROM waypoints ORDER BY id ASC; `) if err != nil { return err } defer rows.Close() for rows.Next() { var id int var name string var ewkbPoint ewkb.Point if err := rows.Scan(&id, &name, &ewkbPoint); err != nil { return err } geometry, err := geojson.Marshal(ewkbPoint.Point) if err != nil { return err } if err := json.NewEncoder(w).Encode(&Waypoint{ ID: id, Name: name, Geometry: geometry, }); err != nil { return err } } return nil }
[ "func", "writeGeoJSON", "(", "db", "*", "sql", ".", "DB", ",", "w", "io", ".", "Writer", ")", "error", "{", "rows", ",", "err", ":=", "db", ".", "Query", "(", "`\n\t\tSELECT id, name, ST_AsEWKB(geom) FROM waypoints ORDER BY id ASC;\n\t`", ")", "\n", "if", "err...
// writeGeoJSON demonstrates reading data from a database in EWKB format and // writing it as GeoJSON.
[ "writeGeoJSON", "demonstrates", "reading", "data", "from", "a", "database", "in", "EWKB", "format", "and", "writing", "it", "as", "GeoJSON", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/examples/postgis/main.go#L104-L132
train
twpayne/go-geom
xy/centroid.go
Centroid
func Centroid(geometry geom.T) (centroid geom.Coord, err error) { switch t := geometry.(type) { case *geom.Point: centroid = PointsCentroid(t) case *geom.MultiPoint: centroid = MultiPointCentroid(t) case *geom.LineString: centroid = LinesCentroid(t) case *geom.LinearRing: centroid = LinearRingsCentroid(t) case *geom.MultiLineString: centroid = MultiLineCentroid(t) case *geom.Polygon: centroid = PolygonsCentroid(t) case *geom.MultiPolygon: centroid = MultiPolygonCentroid(t) default: err = fmt.Errorf("%v is not a supported type for centroid calculation", t) } return centroid, err }
go
func Centroid(geometry geom.T) (centroid geom.Coord, err error) { switch t := geometry.(type) { case *geom.Point: centroid = PointsCentroid(t) case *geom.MultiPoint: centroid = MultiPointCentroid(t) case *geom.LineString: centroid = LinesCentroid(t) case *geom.LinearRing: centroid = LinearRingsCentroid(t) case *geom.MultiLineString: centroid = MultiLineCentroid(t) case *geom.Polygon: centroid = PolygonsCentroid(t) case *geom.MultiPolygon: centroid = MultiPolygonCentroid(t) default: err = fmt.Errorf("%v is not a supported type for centroid calculation", t) } return centroid, err }
[ "func", "Centroid", "(", "geometry", "geom", ".", "T", ")", "(", "centroid", "geom", ".", "Coord", ",", "err", "error", ")", "{", "switch", "t", ":=", "geometry", ".", "(", "type", ")", "{", "case", "*", "geom", ".", "Point", ":", "centroid", "=", ...
// Centroid calculates the centroid of the geometry. The centroid may be outside of the geometry depending // on the topology of the geometry
[ "Centroid", "calculates", "the", "centroid", "of", "the", "geometry", ".", "The", "centroid", "may", "be", "outside", "of", "the", "geometry", "depending", "on", "the", "topology", "of", "the", "geometry" ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/centroid.go#L11-L32
train
twpayne/go-geom
bounds.go
NewBounds
func NewBounds(layout Layout) *Bounds { stride := layout.Stride() min, max := make(Coord, stride), make(Coord, stride) for i := 0; i < stride; i++ { min[i], max[i] = math.Inf(1), math.Inf(-1) } return &Bounds{ layout: layout, min: min, max: max, } }
go
func NewBounds(layout Layout) *Bounds { stride := layout.Stride() min, max := make(Coord, stride), make(Coord, stride) for i := 0; i < stride; i++ { min[i], max[i] = math.Inf(1), math.Inf(-1) } return &Bounds{ layout: layout, min: min, max: max, } }
[ "func", "NewBounds", "(", "layout", "Layout", ")", "*", "Bounds", "{", "stride", ":=", "layout", ".", "Stride", "(", ")", "\n", "min", ",", "max", ":=", "make", "(", "Coord", ",", "stride", ")", ",", "make", "(", "Coord", ",", "stride", ")", "\n", ...
// NewBounds creates a new Bounds.
[ "NewBounds", "creates", "a", "new", "Bounds", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/bounds.go#L13-L24
train
twpayne/go-geom
bounds.go
Extend
func (b *Bounds) Extend(g T) *Bounds { b.extendLayout(g.Layout()) if b.layout == XYZM && g.Layout() == XYM { return b.extendXYZMFlatCoordsWithXYM(g.FlatCoords(), 0, len(g.FlatCoords())) } return b.extendFlatCoords(g.FlatCoords(), 0, len(g.FlatCoords()), g.Stride()) }
go
func (b *Bounds) Extend(g T) *Bounds { b.extendLayout(g.Layout()) if b.layout == XYZM && g.Layout() == XYM { return b.extendXYZMFlatCoordsWithXYM(g.FlatCoords(), 0, len(g.FlatCoords())) } return b.extendFlatCoords(g.FlatCoords(), 0, len(g.FlatCoords()), g.Stride()) }
[ "func", "(", "b", "*", "Bounds", ")", "Extend", "(", "g", "T", ")", "*", "Bounds", "{", "b", ".", "extendLayout", "(", "g", ".", "Layout", "(", ")", ")", "\n", "if", "b", ".", "layout", "==", "XYZM", "&&", "g", ".", "Layout", "(", ")", "==", ...
// Extend extends b to include geometry g.
[ "Extend", "extends", "b", "to", "include", "geometry", "g", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/bounds.go#L32-L38
train
twpayne/go-geom
bounds.go
IsEmpty
func (b *Bounds) IsEmpty() bool { if b.layout == NoLayout { return true } for i, stride := 0, b.layout.Stride(); i < stride; i++ { if b.max[i] < b.min[i] { return true } } return false }
go
func (b *Bounds) IsEmpty() bool { if b.layout == NoLayout { return true } for i, stride := 0, b.layout.Stride(); i < stride; i++ { if b.max[i] < b.min[i] { return true } } return false }
[ "func", "(", "b", "*", "Bounds", ")", "IsEmpty", "(", ")", "bool", "{", "if", "b", ".", "layout", "==", "NoLayout", "{", "return", "true", "\n", "}", "\n", "for", "i", ",", "stride", ":=", "0", ",", "b", ".", "layout", ".", "Stride", "(", ")", ...
// IsEmpty returns true if b is empty.
[ "IsEmpty", "returns", "true", "if", "b", "is", "empty", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/bounds.go#L41-L51
train
twpayne/go-geom
bounds.go
Overlaps
func (b *Bounds) Overlaps(layout Layout, b2 *Bounds) bool { for i, stride := 0, layout.Stride(); i < stride; i++ { if b.min[i] > b2.max[i] || b.max[i] < b2.min[i] { return false } } return true }
go
func (b *Bounds) Overlaps(layout Layout, b2 *Bounds) bool { for i, stride := 0, layout.Stride(); i < stride; i++ { if b.min[i] > b2.max[i] || b.max[i] < b2.min[i] { return false } } return true }
[ "func", "(", "b", "*", "Bounds", ")", "Overlaps", "(", "layout", "Layout", ",", "b2", "*", "Bounds", ")", "bool", "{", "for", "i", ",", "stride", ":=", "0", ",", "layout", ".", "Stride", "(", ")", ";", "i", "<", "stride", ";", "i", "++", "{", ...
// Overlaps returns true if b overlaps b2 in layout.
[ "Overlaps", "returns", "true", "if", "b", "overlaps", "b2", "in", "layout", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/bounds.go#L69-L76
train
twpayne/go-geom
bounds.go
Polygon
func (b *Bounds) Polygon() *Polygon { if b.IsEmpty() { return NewPolygonFlat(XY, nil, nil) } x1, y1 := b.min[0], b.min[1] x2, y2 := b.max[0], b.max[1] flatCoords := []float64{ x1, y1, x1, y2, x2, y2, x2, y1, x1, y1, } return NewPolygonFlat(XY, flatCoords, []int{len(flatCoords)}) }
go
func (b *Bounds) Polygon() *Polygon { if b.IsEmpty() { return NewPolygonFlat(XY, nil, nil) } x1, y1 := b.min[0], b.min[1] x2, y2 := b.max[0], b.max[1] flatCoords := []float64{ x1, y1, x1, y2, x2, y2, x2, y1, x1, y1, } return NewPolygonFlat(XY, flatCoords, []int{len(flatCoords)}) }
[ "func", "(", "b", "*", "Bounds", ")", "Polygon", "(", ")", "*", "Polygon", "{", "if", "b", ".", "IsEmpty", "(", ")", "{", "return", "NewPolygonFlat", "(", "XY", ",", "nil", ",", "nil", ")", "\n", "}", "\n", "x1", ",", "y1", ":=", "b", ".", "m...
// Polygon returns b as a two-dimensional Polygon.
[ "Polygon", "returns", "b", "as", "a", "two", "-", "dimensional", "Polygon", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/bounds.go#L79-L93
train
twpayne/go-geom
bounds.go
SetCoords
func (b *Bounds) SetCoords(min, max Coord) *Bounds { b.min = Coord(make([]float64, b.layout.Stride())) b.max = Coord(make([]float64, b.layout.Stride())) for i := 0; i < b.layout.Stride(); i++ { b.min[i] = math.Min(min[i], max[i]) b.max[i] = math.Max(min[i], max[i]) } return b }
go
func (b *Bounds) SetCoords(min, max Coord) *Bounds { b.min = Coord(make([]float64, b.layout.Stride())) b.max = Coord(make([]float64, b.layout.Stride())) for i := 0; i < b.layout.Stride(); i++ { b.min[i] = math.Min(min[i], max[i]) b.max[i] = math.Max(min[i], max[i]) } return b }
[ "func", "(", "b", "*", "Bounds", ")", "SetCoords", "(", "min", ",", "max", "Coord", ")", "*", "Bounds", "{", "b", ".", "min", "=", "Coord", "(", "make", "(", "[", "]", "float64", ",", "b", ".", "layout", ".", "Stride", "(", ")", ")", ")", "\n...
// SetCoords sets the minimum and maximum values of the Bounds.
[ "SetCoords", "sets", "the", "minimum", "and", "maximum", "values", "of", "the", "Bounds", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/bounds.go#L113-L121
train
twpayne/go-geom
derived.gen.go
deriveCloneBounds
func deriveCloneBounds(src *Bounds) *Bounds { if src == nil { return nil } dst := new(Bounds) deriveDeepCopy(dst, src) return dst }
go
func deriveCloneBounds(src *Bounds) *Bounds { if src == nil { return nil } dst := new(Bounds) deriveDeepCopy(dst, src) return dst }
[ "func", "deriveCloneBounds", "(", "src", "*", "Bounds", ")", "*", "Bounds", "{", "if", "src", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "dst", ":=", "new", "(", "Bounds", ")", "\n", "deriveDeepCopy", "(", "dst", ",", "src", ")", "\n", "re...
// deriveCloneBounds returns a clone of the src parameter.
[ "deriveCloneBounds", "returns", "a", "clone", "of", "the", "src", "parameter", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L6-L13
train
twpayne/go-geom
derived.gen.go
deriveCloneCoord
func deriveCloneCoord(src Coord) Coord { if src == nil { return nil } dst := make(Coord, len(src)) deriveDeepCopy_(dst, src) return dst }
go
func deriveCloneCoord(src Coord) Coord { if src == nil { return nil } dst := make(Coord, len(src)) deriveDeepCopy_(dst, src) return dst }
[ "func", "deriveCloneCoord", "(", "src", "Coord", ")", "Coord", "{", "if", "src", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "dst", ":=", "make", "(", "Coord", ",", "len", "(", "src", ")", ")", "\n", "deriveDeepCopy_", "(", "dst", ",", "src...
// deriveCloneCoord returns a clone of the src parameter.
[ "deriveCloneCoord", "returns", "a", "clone", "of", "the", "src", "parameter", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L16-L23
train
twpayne/go-geom
derived.gen.go
deriveCloneLinearRing
func deriveCloneLinearRing(src *LinearRing) *LinearRing { if src == nil { return nil } dst := new(LinearRing) deriveDeepCopy_1(dst, src) return dst }
go
func deriveCloneLinearRing(src *LinearRing) *LinearRing { if src == nil { return nil } dst := new(LinearRing) deriveDeepCopy_1(dst, src) return dst }
[ "func", "deriveCloneLinearRing", "(", "src", "*", "LinearRing", ")", "*", "LinearRing", "{", "if", "src", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "dst", ":=", "new", "(", "LinearRing", ")", "\n", "deriveDeepCopy_1", "(", "dst", ",", "src", ...
// deriveCloneLinearRing returns a clone of the src parameter.
[ "deriveCloneLinearRing", "returns", "a", "clone", "of", "the", "src", "parameter", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L26-L33
train
twpayne/go-geom
derived.gen.go
deriveCloneLineString
func deriveCloneLineString(src *LineString) *LineString { if src == nil { return nil } dst := new(LineString) deriveDeepCopy_2(dst, src) return dst }
go
func deriveCloneLineString(src *LineString) *LineString { if src == nil { return nil } dst := new(LineString) deriveDeepCopy_2(dst, src) return dst }
[ "func", "deriveCloneLineString", "(", "src", "*", "LineString", ")", "*", "LineString", "{", "if", "src", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "dst", ":=", "new", "(", "LineString", ")", "\n", "deriveDeepCopy_2", "(", "dst", ",", "src", ...
// deriveCloneLineString returns a clone of the src parameter.
[ "deriveCloneLineString", "returns", "a", "clone", "of", "the", "src", "parameter", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L36-L43
train
twpayne/go-geom
derived.gen.go
deriveCloneMultiLineString
func deriveCloneMultiLineString(src *MultiLineString) *MultiLineString { if src == nil { return nil } dst := new(MultiLineString) deriveDeepCopy_3(dst, src) return dst }
go
func deriveCloneMultiLineString(src *MultiLineString) *MultiLineString { if src == nil { return nil } dst := new(MultiLineString) deriveDeepCopy_3(dst, src) return dst }
[ "func", "deriveCloneMultiLineString", "(", "src", "*", "MultiLineString", ")", "*", "MultiLineString", "{", "if", "src", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "dst", ":=", "new", "(", "MultiLineString", ")", "\n", "deriveDeepCopy_3", "(", "dst"...
// deriveCloneMultiLineString returns a clone of the src parameter.
[ "deriveCloneMultiLineString", "returns", "a", "clone", "of", "the", "src", "parameter", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L46-L53
train
twpayne/go-geom
derived.gen.go
deriveCloneMultiPoint
func deriveCloneMultiPoint(src *MultiPoint) *MultiPoint { if src == nil { return nil } dst := new(MultiPoint) deriveDeepCopy_4(dst, src) return dst }
go
func deriveCloneMultiPoint(src *MultiPoint) *MultiPoint { if src == nil { return nil } dst := new(MultiPoint) deriveDeepCopy_4(dst, src) return dst }
[ "func", "deriveCloneMultiPoint", "(", "src", "*", "MultiPoint", ")", "*", "MultiPoint", "{", "if", "src", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "dst", ":=", "new", "(", "MultiPoint", ")", "\n", "deriveDeepCopy_4", "(", "dst", ",", "src", ...
// deriveCloneMultiPoint returns a clone of the src parameter.
[ "deriveCloneMultiPoint", "returns", "a", "clone", "of", "the", "src", "parameter", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L56-L63
train
twpayne/go-geom
derived.gen.go
deriveCloneMultiPolygon
func deriveCloneMultiPolygon(src *MultiPolygon) *MultiPolygon { if src == nil { return nil } dst := new(MultiPolygon) deriveDeepCopy_5(dst, src) return dst }
go
func deriveCloneMultiPolygon(src *MultiPolygon) *MultiPolygon { if src == nil { return nil } dst := new(MultiPolygon) deriveDeepCopy_5(dst, src) return dst }
[ "func", "deriveCloneMultiPolygon", "(", "src", "*", "MultiPolygon", ")", "*", "MultiPolygon", "{", "if", "src", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "dst", ":=", "new", "(", "MultiPolygon", ")", "\n", "deriveDeepCopy_5", "(", "dst", ",", "...
// deriveCloneMultiPolygon returns a clone of the src parameter.
[ "deriveCloneMultiPolygon", "returns", "a", "clone", "of", "the", "src", "parameter", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L66-L73
train
twpayne/go-geom
derived.gen.go
deriveClonePoint
func deriveClonePoint(src *Point) *Point { if src == nil { return nil } dst := new(Point) deriveDeepCopy_6(dst, src) return dst }
go
func deriveClonePoint(src *Point) *Point { if src == nil { return nil } dst := new(Point) deriveDeepCopy_6(dst, src) return dst }
[ "func", "deriveClonePoint", "(", "src", "*", "Point", ")", "*", "Point", "{", "if", "src", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "dst", ":=", "new", "(", "Point", ")", "\n", "deriveDeepCopy_6", "(", "dst", ",", "src", ")", "\n", "retu...
// deriveClonePoint returns a clone of the src parameter.
[ "deriveClonePoint", "returns", "a", "clone", "of", "the", "src", "parameter", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L76-L83
train
twpayne/go-geom
derived.gen.go
deriveClonePolygon
func deriveClonePolygon(src *Polygon) *Polygon { if src == nil { return nil } dst := new(Polygon) deriveDeepCopy_7(dst, src) return dst }
go
func deriveClonePolygon(src *Polygon) *Polygon { if src == nil { return nil } dst := new(Polygon) deriveDeepCopy_7(dst, src) return dst }
[ "func", "deriveClonePolygon", "(", "src", "*", "Polygon", ")", "*", "Polygon", "{", "if", "src", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "dst", ":=", "new", "(", "Polygon", ")", "\n", "deriveDeepCopy_7", "(", "dst", ",", "src", ")", "\n",...
// deriveClonePolygon returns a clone of the src parameter.
[ "deriveClonePolygon", "returns", "a", "clone", "of", "the", "src", "parameter", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L86-L93
train
twpayne/go-geom
derived.gen.go
deriveDeepCopy_1
func deriveDeepCopy_1(dst, src *LinearRing) { func() { field := new(geom1) deriveDeepCopy_8(field, &src.geom1) dst.geom1 = *field }() }
go
func deriveDeepCopy_1(dst, src *LinearRing) { func() { field := new(geom1) deriveDeepCopy_8(field, &src.geom1) dst.geom1 = *field }() }
[ "func", "deriveDeepCopy_1", "(", "dst", ",", "src", "*", "LinearRing", ")", "{", "func", "(", ")", "{", "field", ":=", "new", "(", "geom1", ")", "\n", "deriveDeepCopy_8", "(", "field", ",", "&", "src", ".", "geom1", ")", "\n", "dst", ".", "geom1", ...
// deriveDeepCopy_1 recursively copies the contents of src into dst.
[ "deriveDeepCopy_1", "recursively", "copies", "the", "contents", "of", "src", "into", "dst", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L142-L148
train
twpayne/go-geom
derived.gen.go
deriveDeepCopy_2
func deriveDeepCopy_2(dst, src *LineString) { func() { field := new(geom1) deriveDeepCopy_8(field, &src.geom1) dst.geom1 = *field }() }
go
func deriveDeepCopy_2(dst, src *LineString) { func() { field := new(geom1) deriveDeepCopy_8(field, &src.geom1) dst.geom1 = *field }() }
[ "func", "deriveDeepCopy_2", "(", "dst", ",", "src", "*", "LineString", ")", "{", "func", "(", ")", "{", "field", ":=", "new", "(", "geom1", ")", "\n", "deriveDeepCopy_8", "(", "field", ",", "&", "src", ".", "geom1", ")", "\n", "dst", ".", "geom1", ...
// deriveDeepCopy_2 recursively copies the contents of src into dst.
[ "deriveDeepCopy_2", "recursively", "copies", "the", "contents", "of", "src", "into", "dst", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L151-L157
train
twpayne/go-geom
derived.gen.go
deriveDeepCopy_3
func deriveDeepCopy_3(dst, src *MultiLineString) { func() { field := new(geom2) deriveDeepCopy_9(field, &src.geom2) dst.geom2 = *field }() }
go
func deriveDeepCopy_3(dst, src *MultiLineString) { func() { field := new(geom2) deriveDeepCopy_9(field, &src.geom2) dst.geom2 = *field }() }
[ "func", "deriveDeepCopy_3", "(", "dst", ",", "src", "*", "MultiLineString", ")", "{", "func", "(", ")", "{", "field", ":=", "new", "(", "geom2", ")", "\n", "deriveDeepCopy_9", "(", "field", ",", "&", "src", ".", "geom2", ")", "\n", "dst", ".", "geom2...
// deriveDeepCopy_3 recursively copies the contents of src into dst.
[ "deriveDeepCopy_3", "recursively", "copies", "the", "contents", "of", "src", "into", "dst", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L160-L166
train
twpayne/go-geom
derived.gen.go
deriveDeepCopy_4
func deriveDeepCopy_4(dst, src *MultiPoint) { func() { field := new(geom1) deriveDeepCopy_8(field, &src.geom1) dst.geom1 = *field }() }
go
func deriveDeepCopy_4(dst, src *MultiPoint) { func() { field := new(geom1) deriveDeepCopy_8(field, &src.geom1) dst.geom1 = *field }() }
[ "func", "deriveDeepCopy_4", "(", "dst", ",", "src", "*", "MultiPoint", ")", "{", "func", "(", ")", "{", "field", ":=", "new", "(", "geom1", ")", "\n", "deriveDeepCopy_8", "(", "field", ",", "&", "src", ".", "geom1", ")", "\n", "dst", ".", "geom1", ...
// deriveDeepCopy_4 recursively copies the contents of src into dst.
[ "deriveDeepCopy_4", "recursively", "copies", "the", "contents", "of", "src", "into", "dst", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L169-L175
train
twpayne/go-geom
derived.gen.go
deriveDeepCopy_5
func deriveDeepCopy_5(dst, src *MultiPolygon) { func() { field := new(geom3) deriveDeepCopy_10(field, &src.geom3) dst.geom3 = *field }() }
go
func deriveDeepCopy_5(dst, src *MultiPolygon) { func() { field := new(geom3) deriveDeepCopy_10(field, &src.geom3) dst.geom3 = *field }() }
[ "func", "deriveDeepCopy_5", "(", "dst", ",", "src", "*", "MultiPolygon", ")", "{", "func", "(", ")", "{", "field", ":=", "new", "(", "geom3", ")", "\n", "deriveDeepCopy_10", "(", "field", ",", "&", "src", ".", "geom3", ")", "\n", "dst", ".", "geom3",...
// deriveDeepCopy_5 recursively copies the contents of src into dst.
[ "deriveDeepCopy_5", "recursively", "copies", "the", "contents", "of", "src", "into", "dst", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L178-L184
train
twpayne/go-geom
derived.gen.go
deriveDeepCopy_6
func deriveDeepCopy_6(dst, src *Point) { func() { field := new(geom0) deriveDeepCopy_11(field, &src.geom0) dst.geom0 = *field }() }
go
func deriveDeepCopy_6(dst, src *Point) { func() { field := new(geom0) deriveDeepCopy_11(field, &src.geom0) dst.geom0 = *field }() }
[ "func", "deriveDeepCopy_6", "(", "dst", ",", "src", "*", "Point", ")", "{", "func", "(", ")", "{", "field", ":=", "new", "(", "geom0", ")", "\n", "deriveDeepCopy_11", "(", "field", ",", "&", "src", ".", "geom0", ")", "\n", "dst", ".", "geom0", "=",...
// deriveDeepCopy_6 recursively copies the contents of src into dst.
[ "deriveDeepCopy_6", "recursively", "copies", "the", "contents", "of", "src", "into", "dst", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L187-L193
train
twpayne/go-geom
derived.gen.go
deriveDeepCopy_7
func deriveDeepCopy_7(dst, src *Polygon) { func() { field := new(geom2) deriveDeepCopy_9(field, &src.geom2) dst.geom2 = *field }() }
go
func deriveDeepCopy_7(dst, src *Polygon) { func() { field := new(geom2) deriveDeepCopy_9(field, &src.geom2) dst.geom2 = *field }() }
[ "func", "deriveDeepCopy_7", "(", "dst", ",", "src", "*", "Polygon", ")", "{", "func", "(", ")", "{", "field", ":=", "new", "(", "geom2", ")", "\n", "deriveDeepCopy_9", "(", "field", ",", "&", "src", ".", "geom2", ")", "\n", "dst", ".", "geom2", "="...
// deriveDeepCopy_7 recursively copies the contents of src into dst.
[ "deriveDeepCopy_7", "recursively", "copies", "the", "contents", "of", "src", "into", "dst", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L196-L202
train
twpayne/go-geom
derived.gen.go
deriveDeepCopy_8
func deriveDeepCopy_8(dst, src *geom1) { func() { field := new(geom0) deriveDeepCopy_11(field, &src.geom0) dst.geom0 = *field }() }
go
func deriveDeepCopy_8(dst, src *geom1) { func() { field := new(geom0) deriveDeepCopy_11(field, &src.geom0) dst.geom0 = *field }() }
[ "func", "deriveDeepCopy_8", "(", "dst", ",", "src", "*", "geom1", ")", "{", "func", "(", ")", "{", "field", ":=", "new", "(", "geom0", ")", "\n", "deriveDeepCopy_11", "(", "field", ",", "&", "src", ".", "geom0", ")", "\n", "dst", ".", "geom0", "=",...
// deriveDeepCopy_8 recursively copies the contents of src into dst.
[ "deriveDeepCopy_8", "recursively", "copies", "the", "contents", "of", "src", "into", "dst", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L205-L211
train
twpayne/go-geom
derived.gen.go
deriveDeepCopy_9
func deriveDeepCopy_9(dst, src *geom2) { func() { field := new(geom1) deriveDeepCopy_8(field, &src.geom1) dst.geom1 = *field }() if src.ends == nil { dst.ends = nil } else { if dst.ends != nil { if len(src.ends) > len(dst.ends) { if cap(dst.ends) >= len(src.ends) { dst.ends = (dst.ends)[:len(src.ends)] } else { dst.ends = make([]int, len(src.ends)) } } else if len(src.ends) < len(dst.ends) { dst.ends = (dst.ends)[:len(src.ends)] } } else { dst.ends = make([]int, len(src.ends)) } copy(dst.ends, src.ends) } }
go
func deriveDeepCopy_9(dst, src *geom2) { func() { field := new(geom1) deriveDeepCopy_8(field, &src.geom1) dst.geom1 = *field }() if src.ends == nil { dst.ends = nil } else { if dst.ends != nil { if len(src.ends) > len(dst.ends) { if cap(dst.ends) >= len(src.ends) { dst.ends = (dst.ends)[:len(src.ends)] } else { dst.ends = make([]int, len(src.ends)) } } else if len(src.ends) < len(dst.ends) { dst.ends = (dst.ends)[:len(src.ends)] } } else { dst.ends = make([]int, len(src.ends)) } copy(dst.ends, src.ends) } }
[ "func", "deriveDeepCopy_9", "(", "dst", ",", "src", "*", "geom2", ")", "{", "func", "(", ")", "{", "field", ":=", "new", "(", "geom1", ")", "\n", "deriveDeepCopy_8", "(", "field", ",", "&", "src", ".", "geom1", ")", "\n", "dst", ".", "geom1", "=", ...
// deriveDeepCopy_9 recursively copies the contents of src into dst.
[ "deriveDeepCopy_9", "recursively", "copies", "the", "contents", "of", "src", "into", "dst", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L214-L238
train
twpayne/go-geom
derived.gen.go
deriveDeepCopy_10
func deriveDeepCopy_10(dst, src *geom3) { func() { field := new(geom1) deriveDeepCopy_8(field, &src.geom1) dst.geom1 = *field }() if src.endss == nil { dst.endss = nil } else { if dst.endss != nil { if len(src.endss) > len(dst.endss) { if cap(dst.endss) >= len(src.endss) { dst.endss = (dst.endss)[:len(src.endss)] } else { dst.endss = make([][]int, len(src.endss)) } } else if len(src.endss) < len(dst.endss) { dst.endss = (dst.endss)[:len(src.endss)] } } else { dst.endss = make([][]int, len(src.endss)) } deriveDeepCopy_12(dst.endss, src.endss) } }
go
func deriveDeepCopy_10(dst, src *geom3) { func() { field := new(geom1) deriveDeepCopy_8(field, &src.geom1) dst.geom1 = *field }() if src.endss == nil { dst.endss = nil } else { if dst.endss != nil { if len(src.endss) > len(dst.endss) { if cap(dst.endss) >= len(src.endss) { dst.endss = (dst.endss)[:len(src.endss)] } else { dst.endss = make([][]int, len(src.endss)) } } else if len(src.endss) < len(dst.endss) { dst.endss = (dst.endss)[:len(src.endss)] } } else { dst.endss = make([][]int, len(src.endss)) } deriveDeepCopy_12(dst.endss, src.endss) } }
[ "func", "deriveDeepCopy_10", "(", "dst", ",", "src", "*", "geom3", ")", "{", "func", "(", ")", "{", "field", ":=", "new", "(", "geom1", ")", "\n", "deriveDeepCopy_8", "(", "field", ",", "&", "src", ".", "geom1", ")", "\n", "dst", ".", "geom1", "=",...
// deriveDeepCopy_10 recursively copies the contents of src into dst.
[ "deriveDeepCopy_10", "recursively", "copies", "the", "contents", "of", "src", "into", "dst", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L241-L265
train
twpayne/go-geom
derived.gen.go
deriveDeepCopy_11
func deriveDeepCopy_11(dst, src *geom0) { dst.layout = src.layout dst.stride = src.stride if src.flatCoords == nil { dst.flatCoords = nil } else { if dst.flatCoords != nil { if len(src.flatCoords) > len(dst.flatCoords) { if cap(dst.flatCoords) >= len(src.flatCoords) { dst.flatCoords = (dst.flatCoords)[:len(src.flatCoords)] } else { dst.flatCoords = make([]float64, len(src.flatCoords)) } } else if len(src.flatCoords) < len(dst.flatCoords) { dst.flatCoords = (dst.flatCoords)[:len(src.flatCoords)] } } else { dst.flatCoords = make([]float64, len(src.flatCoords)) } copy(dst.flatCoords, src.flatCoords) } dst.srid = src.srid }
go
func deriveDeepCopy_11(dst, src *geom0) { dst.layout = src.layout dst.stride = src.stride if src.flatCoords == nil { dst.flatCoords = nil } else { if dst.flatCoords != nil { if len(src.flatCoords) > len(dst.flatCoords) { if cap(dst.flatCoords) >= len(src.flatCoords) { dst.flatCoords = (dst.flatCoords)[:len(src.flatCoords)] } else { dst.flatCoords = make([]float64, len(src.flatCoords)) } } else if len(src.flatCoords) < len(dst.flatCoords) { dst.flatCoords = (dst.flatCoords)[:len(src.flatCoords)] } } else { dst.flatCoords = make([]float64, len(src.flatCoords)) } copy(dst.flatCoords, src.flatCoords) } dst.srid = src.srid }
[ "func", "deriveDeepCopy_11", "(", "dst", ",", "src", "*", "geom0", ")", "{", "dst", ".", "layout", "=", "src", ".", "layout", "\n", "dst", ".", "stride", "=", "src", ".", "stride", "\n", "if", "src", ".", "flatCoords", "==", "nil", "{", "dst", ".",...
// deriveDeepCopy_11 recursively copies the contents of src into dst.
[ "deriveDeepCopy_11", "recursively", "copies", "the", "contents", "of", "src", "into", "dst", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L268-L290
train
twpayne/go-geom
derived.gen.go
deriveDeepCopy_12
func deriveDeepCopy_12(dst, src [][]int) { for src_i, src_value := range src { if src_value == nil { dst[src_i] = nil } else { if dst[src_i] != nil { if len(src_value) > len(dst[src_i]) { if cap(dst[src_i]) >= len(src_value) { dst[src_i] = (dst[src_i])[:len(src_value)] } else { dst[src_i] = make([]int, len(src_value)) } } else if len(src_value) < len(dst[src_i]) { dst[src_i] = (dst[src_i])[:len(src_value)] } } else { dst[src_i] = make([]int, len(src_value)) } copy(dst[src_i], src_value) } } }
go
func deriveDeepCopy_12(dst, src [][]int) { for src_i, src_value := range src { if src_value == nil { dst[src_i] = nil } else { if dst[src_i] != nil { if len(src_value) > len(dst[src_i]) { if cap(dst[src_i]) >= len(src_value) { dst[src_i] = (dst[src_i])[:len(src_value)] } else { dst[src_i] = make([]int, len(src_value)) } } else if len(src_value) < len(dst[src_i]) { dst[src_i] = (dst[src_i])[:len(src_value)] } } else { dst[src_i] = make([]int, len(src_value)) } copy(dst[src_i], src_value) } } }
[ "func", "deriveDeepCopy_12", "(", "dst", ",", "src", "[", "]", "[", "]", "int", ")", "{", "for", "src_i", ",", "src_value", ":=", "range", "src", "{", "if", "src_value", "==", "nil", "{", "dst", "[", "src_i", "]", "=", "nil", "\n", "}", "else", "...
// deriveDeepCopy_12 recursively copies the contents of src into dst.
[ "deriveDeepCopy_12", "recursively", "copies", "the", "contents", "of", "src", "into", "dst", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/derived.gen.go#L293-L314
train
twpayne/go-geom
linearring.go
NewLinearRingFlat
func NewLinearRingFlat(layout Layout, flatCoords []float64) *LinearRing { g := new(LinearRing) g.layout = layout g.stride = layout.Stride() g.flatCoords = flatCoords return g }
go
func NewLinearRingFlat(layout Layout, flatCoords []float64) *LinearRing { g := new(LinearRing) g.layout = layout g.stride = layout.Stride() g.flatCoords = flatCoords return g }
[ "func", "NewLinearRingFlat", "(", "layout", "Layout", ",", "flatCoords", "[", "]", "float64", ")", "*", "LinearRing", "{", "g", ":=", "new", "(", "LinearRing", ")", "\n", "g", ".", "layout", "=", "layout", "\n", "g", ".", "stride", "=", "layout", ".", ...
// NewLinearRingFlat returns a new LinearRing with the given flat coordinates.
[ "NewLinearRingFlat", "returns", "a", "new", "LinearRing", "with", "the", "given", "flat", "coordinates", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/linearring.go#L14-L20
train
twpayne/go-geom
linearring.go
Area
func (g *LinearRing) Area() float64 { return doubleArea1(g.flatCoords, 0, len(g.flatCoords), g.stride) / 2 }
go
func (g *LinearRing) Area() float64 { return doubleArea1(g.flatCoords, 0, len(g.flatCoords), g.stride) / 2 }
[ "func", "(", "g", "*", "LinearRing", ")", "Area", "(", ")", "float64", "{", "return", "doubleArea1", "(", "g", ".", "flatCoords", ",", "0", ",", "len", "(", "g", ".", "flatCoords", ")", ",", "g", ".", "stride", ")", "/", "2", "\n", "}" ]
// Area returns the the area.
[ "Area", "returns", "the", "the", "area", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/linearring.go#L23-L25
train
twpayne/go-geom
linearring.go
Length
func (g *LinearRing) Length() float64 { return length1(g.flatCoords, 0, len(g.flatCoords), g.stride) }
go
func (g *LinearRing) Length() float64 { return length1(g.flatCoords, 0, len(g.flatCoords), g.stride) }
[ "func", "(", "g", "*", "LinearRing", ")", "Length", "(", ")", "float64", "{", "return", "length1", "(", "g", ".", "flatCoords", ",", "0", ",", "len", "(", "g", ".", "flatCoords", ")", ",", "g", ".", "stride", ")", "\n", "}" ]
// Length returns the length of the perimeter.
[ "Length", "returns", "the", "length", "of", "the", "perimeter", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/linearring.go#L38-L40
train
twpayne/go-geom
linearring.go
MustSetCoords
func (g *LinearRing) MustSetCoords(coords []Coord) *LinearRing { Must(g.SetCoords(coords)) return g }
go
func (g *LinearRing) MustSetCoords(coords []Coord) *LinearRing { Must(g.SetCoords(coords)) return g }
[ "func", "(", "g", "*", "LinearRing", ")", "MustSetCoords", "(", "coords", "[", "]", "Coord", ")", "*", "LinearRing", "{", "Must", "(", "g", ".", "SetCoords", "(", "coords", ")", ")", "\n", "return", "g", "\n", "}" ]
// MustSetCoords sets the coordinates and panics if there is any error.
[ "MustSetCoords", "sets", "the", "coordinates", "and", "panics", "if", "there", "is", "any", "error", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/linearring.go#L43-L46
train
twpayne/go-geom
linearring.go
SetCoords
func (g *LinearRing) SetCoords(coords []Coord) (*LinearRing, error) { if err := g.setCoords(coords); err != nil { return nil, err } return g, nil }
go
func (g *LinearRing) SetCoords(coords []Coord) (*LinearRing, error) { if err := g.setCoords(coords); err != nil { return nil, err } return g, nil }
[ "func", "(", "g", "*", "LinearRing", ")", "SetCoords", "(", "coords", "[", "]", "Coord", ")", "(", "*", "LinearRing", ",", "error", ")", "{", "if", "err", ":=", "g", ".", "setCoords", "(", "coords", ")", ";", "err", "!=", "nil", "{", "return", "n...
// SetCoords sets the coordinates.
[ "SetCoords", "sets", "the", "coordinates", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/linearring.go#L49-L54
train
twpayne/go-geom
xy/internal/coord_stack.go
Push
func (stack *CoordStack) Push(data []float64, idx int) []float64 { c := data[idx : idx+stack.stride] stack.Data = append(stack.Data, c...) return c }
go
func (stack *CoordStack) Push(data []float64, idx int) []float64 { c := data[idx : idx+stack.stride] stack.Data = append(stack.Data, c...) return c }
[ "func", "(", "stack", "*", "CoordStack", ")", "Push", "(", "data", "[", "]", "float64", ",", "idx", "int", ")", "[", "]", "float64", "{", "c", ":=", "data", "[", "idx", ":", "idx", "+", "stack", ".", "stride", "]", "\n", "stack", ".", "Data", "...
// Push puts the coordinate at the location idx onto the stack.
[ "Push", "puts", "the", "coordinate", "at", "the", "location", "idx", "onto", "the", "stack", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/internal/coord_stack.go#L21-L25
train
twpayne/go-geom
xy/internal/coord_stack.go
Pop
func (stack *CoordStack) Pop() ([]float64, int) { numOrds := len(stack.Data) start := numOrds - stack.stride coord := stack.Data[start:numOrds] stack.Data = stack.Data[:start] return coord, stack.Size() }
go
func (stack *CoordStack) Pop() ([]float64, int) { numOrds := len(stack.Data) start := numOrds - stack.stride coord := stack.Data[start:numOrds] stack.Data = stack.Data[:start] return coord, stack.Size() }
[ "func", "(", "stack", "*", "CoordStack", ")", "Pop", "(", ")", "(", "[", "]", "float64", ",", "int", ")", "{", "numOrds", ":=", "len", "(", "stack", ".", "Data", ")", "\n", "start", ":=", "numOrds", "-", "stack", ".", "stride", "\n", "coord", ":=...
// Pop the last pushed coordinate off the stack and return the coordinate
[ "Pop", "the", "last", "pushed", "coordinate", "off", "the", "stack", "and", "return", "the", "coordinate" ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/internal/coord_stack.go#L28-L34
train
twpayne/go-geom
xy/internal/coord_stack.go
Peek
func (stack *CoordStack) Peek() []float64 { numOrds := len(stack.Data) start := numOrds - stack.stride coord := stack.Data[start:numOrds] return coord }
go
func (stack *CoordStack) Peek() []float64 { numOrds := len(stack.Data) start := numOrds - stack.stride coord := stack.Data[start:numOrds] return coord }
[ "func", "(", "stack", "*", "CoordStack", ")", "Peek", "(", ")", "[", "]", "float64", "{", "numOrds", ":=", "len", "(", "stack", ".", "Data", ")", "\n", "start", ":=", "numOrds", "-", "stack", ".", "stride", "\n", "coord", ":=", "stack", ".", "Data"...
// Peek returns the most recently pushed coord without modifying the stack
[ "Peek", "returns", "the", "most", "recently", "pushed", "coord", "without", "modifying", "the", "stack" ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/internal/coord_stack.go#L37-L42
train
twpayne/go-geom
xy/location/location.go
Symbol
func (t Type) Symbol() rune { switch t { case Exterior: return 'e' case Boundary: return 'b' case Interior: return 'i' case None: return '-' } panic(fmt.Sprintf("Unknown location value: %v", int(t))) }
go
func (t Type) Symbol() rune { switch t { case Exterior: return 'e' case Boundary: return 'b' case Interior: return 'i' case None: return '-' } panic(fmt.Sprintf("Unknown location value: %v", int(t))) }
[ "func", "(", "t", "Type", ")", "Symbol", "(", ")", "rune", "{", "switch", "t", "{", "case", "Exterior", ":", "return", "'e'", "\n", "case", "Boundary", ":", "return", "'b'", "\n", "case", "Interior", ":", "return", "'i'", "\n", "case", "None", ":", ...
// Symbol converts the location value to a location symbol, for example, Exterior => 'e' // locationValue // Returns either 'e', 'b', 'i' or '-'
[ "Symbol", "converts", "the", "location", "value", "to", "a", "location", "symbol", "for", "example", "Exterior", "=", ">", "e", "locationValue", "Returns", "either", "e", "b", "i", "or", "-" ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/xy/location/location.go#L44-L56
train
twpayne/go-geom
point.go
NewPoint
func NewPoint(l Layout) *Point { return NewPointFlat(l, make([]float64, l.Stride())) }
go
func NewPoint(l Layout) *Point { return NewPointFlat(l, make([]float64, l.Stride())) }
[ "func", "NewPoint", "(", "l", "Layout", ")", "*", "Point", "{", "return", "NewPointFlat", "(", "l", ",", "make", "(", "[", "]", "float64", ",", "l", ".", "Stride", "(", ")", ")", ")", "\n", "}" ]
// NewPoint allocates a new Point with layout l and all values zero.
[ "NewPoint", "allocates", "a", "new", "Point", "with", "layout", "l", "and", "all", "values", "zero", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/point.go#L9-L11
train
twpayne/go-geom
point.go
NewPointFlat
func NewPointFlat(l Layout, flatCoords []float64) *Point { g := new(Point) g.layout = l g.stride = l.Stride() g.flatCoords = flatCoords return g }
go
func NewPointFlat(l Layout, flatCoords []float64) *Point { g := new(Point) g.layout = l g.stride = l.Stride() g.flatCoords = flatCoords return g }
[ "func", "NewPointFlat", "(", "l", "Layout", ",", "flatCoords", "[", "]", "float64", ")", "*", "Point", "{", "g", ":=", "new", "(", "Point", ")", "\n", "g", ".", "layout", "=", "l", "\n", "g", ".", "stride", "=", "l", ".", "Stride", "(", ")", "\...
// NewPointFlat allocates a new Point with layout l and flat coordinates flatCoords.
[ "NewPointFlat", "allocates", "a", "new", "Point", "with", "layout", "l", "and", "flat", "coordinates", "flatCoords", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/point.go#L14-L20
train
twpayne/go-geom
point.go
MustSetCoords
func (g *Point) MustSetCoords(coords Coord) *Point { Must(g.SetCoords(coords)) return g }
go
func (g *Point) MustSetCoords(coords Coord) *Point { Must(g.SetCoords(coords)) return g }
[ "func", "(", "g", "*", "Point", ")", "MustSetCoords", "(", "coords", "Coord", ")", "*", "Point", "{", "Must", "(", "g", ".", "SetCoords", "(", "coords", ")", ")", "\n", "return", "g", "\n", "}" ]
// MustSetCoords is like SetCoords but panics on any error.
[ "MustSetCoords", "is", "like", "SetCoords", "but", "panics", "on", "any", "error", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/point.go#L43-L46
train
twpayne/go-geom
point.go
Z
func (g *Point) Z() float64 { zIndex := g.layout.ZIndex() if zIndex == -1 { return 0 } return g.flatCoords[zIndex] }
go
func (g *Point) Z() float64 { zIndex := g.layout.ZIndex() if zIndex == -1 { return 0 } return g.flatCoords[zIndex] }
[ "func", "(", "g", "*", "Point", ")", "Z", "(", ")", "float64", "{", "zIndex", ":=", "g", ".", "layout", ".", "ZIndex", "(", ")", "\n", "if", "zIndex", "==", "-", "1", "{", "return", "0", "\n", "}", "\n", "return", "g", ".", "flatCoords", "[", ...
// Z returns g's Z-coordinate, or zero if g has no Z-coordinate.
[ "Z", "returns", "g", "s", "Z", "-", "coordinate", "or", "zero", "if", "g", "has", "no", "Z", "-", "coordinate", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/point.go#L78-L84
train
twpayne/go-geom
point.go
M
func (g *Point) M() float64 { mIndex := g.layout.MIndex() if mIndex == -1 { return 0 } return g.flatCoords[mIndex] }
go
func (g *Point) M() float64 { mIndex := g.layout.MIndex() if mIndex == -1 { return 0 } return g.flatCoords[mIndex] }
[ "func", "(", "g", "*", "Point", ")", "M", "(", ")", "float64", "{", "mIndex", ":=", "g", ".", "layout", ".", "MIndex", "(", ")", "\n", "if", "mIndex", "==", "-", "1", "{", "return", "0", "\n", "}", "\n", "return", "g", ".", "flatCoords", "[", ...
// M returns g's M-coordinate, or zero if g has no M-coordinate.
[ "M", "returns", "g", "s", "M", "-", "coordinate", "or", "zero", "if", "g", "has", "no", "M", "-", "coordinate", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/point.go#L87-L93
train
twpayne/go-geom
encoding/ewkb/sql.go
Value
func (ls *LineString) Value() (driver.Value, error) { if ls.LineString == nil { return nil, nil } return value(ls.LineString) }
go
func (ls *LineString) Value() (driver.Value, error) { if ls.LineString == nil { return nil, nil } return value(ls.LineString) }
[ "func", "(", "ls", "*", "LineString", ")", "Value", "(", ")", "(", "driver", ".", "Value", ",", "error", ")", "{", "if", "ls", ".", "LineString", "==", "nil", "{", "return", "nil", ",", "nil", "\n", "}", "\n", "return", "value", "(", "ls", ".", ...
// Value returns the EWKB encoding of ls.
[ "Value", "returns", "the", "EWKB", "encoding", "of", "ls", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/ewkb/sql.go#L126-L131
train
twpayne/go-geom
encoding/ewkb/sql.go
Value
func (mls *MultiLineString) Value() (driver.Value, error) { if mls.MultiLineString == nil { return nil, nil } return value(mls.MultiLineString) }
go
func (mls *MultiLineString) Value() (driver.Value, error) { if mls.MultiLineString == nil { return nil, nil } return value(mls.MultiLineString) }
[ "func", "(", "mls", "*", "MultiLineString", ")", "Value", "(", ")", "(", "driver", ".", "Value", ",", "error", ")", "{", "if", "mls", ".", "MultiLineString", "==", "nil", "{", "return", "nil", ",", "nil", "\n", "}", "\n", "return", "value", "(", "m...
// Value returns the EWKB encoding of mls.
[ "Value", "returns", "the", "EWKB", "encoding", "of", "mls", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/ewkb/sql.go#L231-L236
train
twpayne/go-geom
encoding/ewkb/sql.go
Value
func (gc *GeometryCollection) Value() (driver.Value, error) { if gc.GeometryCollection == nil { return nil, nil } return value(gc.GeometryCollection) }
go
func (gc *GeometryCollection) Value() (driver.Value, error) { if gc.GeometryCollection == nil { return nil, nil } return value(gc.GeometryCollection) }
[ "func", "(", "gc", "*", "GeometryCollection", ")", "Value", "(", ")", "(", "driver", ".", "Value", ",", "error", ")", "{", "if", "gc", ".", "GeometryCollection", "==", "nil", "{", "return", "nil", ",", "nil", "\n", "}", "\n", "return", "value", "(", ...
// Value returns the EWKB encoding of gc.
[ "Value", "returns", "the", "EWKB", "encoding", "of", "gc", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/ewkb/sql.go#L301-L306
train
twpayne/go-geom
encoding/wkbcommon/wkbcommon.go
ReadFlatCoords0
func ReadFlatCoords0(r io.Reader, byteOrder binary.ByteOrder, stride int) ([]float64, error) { coord := make([]float64, stride) if err := ReadFloatArray(r, byteOrder, coord); err != nil { return nil, err } return coord, nil }
go
func ReadFlatCoords0(r io.Reader, byteOrder binary.ByteOrder, stride int) ([]float64, error) { coord := make([]float64, stride) if err := ReadFloatArray(r, byteOrder, coord); err != nil { return nil, err } return coord, nil }
[ "func", "ReadFlatCoords0", "(", "r", "io", ".", "Reader", ",", "byteOrder", "binary", ".", "ByteOrder", ",", "stride", "int", ")", "(", "[", "]", "float64", ",", "error", ")", "{", "coord", ":=", "make", "(", "[", "]", "float64", ",", "stride", ")", ...
// ReadFlatCoords0 reads flat coordinates 0.
[ "ReadFlatCoords0", "reads", "flat", "coordinates", "0", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/wkbcommon/wkbcommon.go#L107-L113
train
twpayne/go-geom
encoding/wkbcommon/wkbcommon.go
ReadFlatCoords1
func ReadFlatCoords1(r io.Reader, byteOrder binary.ByteOrder, stride int) ([]float64, error) { n, err := ReadUInt32(r, byteOrder) if err != nil { return nil, err } if limit := MaxGeometryElements[1]; limit >= 0 && int(n) > limit { return nil, ErrGeometryTooLarge{Level: 1, N: int(n), Limit: limit} } flatCoords := make([]float64, int(n)*stride) if err := ReadFloatArray(r, byteOrder, flatCoords); err != nil { return nil, err } return flatCoords, nil }
go
func ReadFlatCoords1(r io.Reader, byteOrder binary.ByteOrder, stride int) ([]float64, error) { n, err := ReadUInt32(r, byteOrder) if err != nil { return nil, err } if limit := MaxGeometryElements[1]; limit >= 0 && int(n) > limit { return nil, ErrGeometryTooLarge{Level: 1, N: int(n), Limit: limit} } flatCoords := make([]float64, int(n)*stride) if err := ReadFloatArray(r, byteOrder, flatCoords); err != nil { return nil, err } return flatCoords, nil }
[ "func", "ReadFlatCoords1", "(", "r", "io", ".", "Reader", ",", "byteOrder", "binary", ".", "ByteOrder", ",", "stride", "int", ")", "(", "[", "]", "float64", ",", "error", ")", "{", "n", ",", "err", ":=", "ReadUInt32", "(", "r", ",", "byteOrder", ")",...
// ReadFlatCoords1 reads flat coordinates 1.
[ "ReadFlatCoords1", "reads", "flat", "coordinates", "1", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/wkbcommon/wkbcommon.go#L116-L129
train
twpayne/go-geom
encoding/wkbcommon/wkbcommon.go
ReadFlatCoords2
func ReadFlatCoords2(r io.Reader, byteOrder binary.ByteOrder, stride int) ([]float64, []int, error) { n, err := ReadUInt32(r, byteOrder) if err != nil { return nil, nil, err } if limit := MaxGeometryElements[2]; limit >= 0 && int(n) > limit { return nil, nil, ErrGeometryTooLarge{Level: 2, N: int(n), Limit: limit} } var flatCoordss []float64 var ends []int for i := 0; i < int(n); i++ { flatCoords, err := ReadFlatCoords1(r, byteOrder, stride) if err != nil { return nil, nil, err } flatCoordss = append(flatCoordss, flatCoords...) ends = append(ends, len(flatCoordss)) } return flatCoordss, ends, nil }
go
func ReadFlatCoords2(r io.Reader, byteOrder binary.ByteOrder, stride int) ([]float64, []int, error) { n, err := ReadUInt32(r, byteOrder) if err != nil { return nil, nil, err } if limit := MaxGeometryElements[2]; limit >= 0 && int(n) > limit { return nil, nil, ErrGeometryTooLarge{Level: 2, N: int(n), Limit: limit} } var flatCoordss []float64 var ends []int for i := 0; i < int(n); i++ { flatCoords, err := ReadFlatCoords1(r, byteOrder, stride) if err != nil { return nil, nil, err } flatCoordss = append(flatCoordss, flatCoords...) ends = append(ends, len(flatCoordss)) } return flatCoordss, ends, nil }
[ "func", "ReadFlatCoords2", "(", "r", "io", ".", "Reader", ",", "byteOrder", "binary", ".", "ByteOrder", ",", "stride", "int", ")", "(", "[", "]", "float64", ",", "[", "]", "int", ",", "error", ")", "{", "n", ",", "err", ":=", "ReadUInt32", "(", "r"...
// ReadFlatCoords2 reads flat coordinates 2.
[ "ReadFlatCoords2", "reads", "flat", "coordinates", "2", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/wkbcommon/wkbcommon.go#L132-L151
train
twpayne/go-geom
encoding/wkbcommon/wkbcommon.go
WriteFlatCoords0
func WriteFlatCoords0(w io.Writer, byteOrder binary.ByteOrder, coord []float64) error { return WriteFloatArray(w, byteOrder, coord) }
go
func WriteFlatCoords0(w io.Writer, byteOrder binary.ByteOrder, coord []float64) error { return WriteFloatArray(w, byteOrder, coord) }
[ "func", "WriteFlatCoords0", "(", "w", "io", ".", "Writer", ",", "byteOrder", "binary", ".", "ByteOrder", ",", "coord", "[", "]", "float64", ")", "error", "{", "return", "WriteFloatArray", "(", "w", ",", "byteOrder", ",", "coord", ")", "\n", "}" ]
// WriteFlatCoords0 writes flat coordinates 0.
[ "WriteFlatCoords0", "writes", "flat", "coordinates", "0", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/wkbcommon/wkbcommon.go#L154-L156
train
twpayne/go-geom
encoding/wkbcommon/wkbcommon.go
WriteFlatCoords1
func WriteFlatCoords1(w io.Writer, byteOrder binary.ByteOrder, coords []float64, stride int) error { if err := WriteUInt32(w, byteOrder, uint32(len(coords)/stride)); err != nil { return err } return WriteFloatArray(w, byteOrder, coords) }
go
func WriteFlatCoords1(w io.Writer, byteOrder binary.ByteOrder, coords []float64, stride int) error { if err := WriteUInt32(w, byteOrder, uint32(len(coords)/stride)); err != nil { return err } return WriteFloatArray(w, byteOrder, coords) }
[ "func", "WriteFlatCoords1", "(", "w", "io", ".", "Writer", ",", "byteOrder", "binary", ".", "ByteOrder", ",", "coords", "[", "]", "float64", ",", "stride", "int", ")", "error", "{", "if", "err", ":=", "WriteUInt32", "(", "w", ",", "byteOrder", ",", "ui...
// WriteFlatCoords1 writes flat coordinates 1.
[ "WriteFlatCoords1", "writes", "flat", "coordinates", "1", "." ]
e21b3afba225b21d05fbcbeb8ece2c79c96554c5
https://github.com/twpayne/go-geom/blob/e21b3afba225b21d05fbcbeb8ece2c79c96554c5/encoding/wkbcommon/wkbcommon.go#L159-L164
train