id int32 0 167k | 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 listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
149,900 | hyperhq/hyperd | integration/client.go | ContainerExecSignal | func (c *HyperClient) ContainerExecSignal(container, execID string, sig int64) error {
req := types.ExecSignalRequest{
ContainerID: container,
ExecID: execID,
Signal: sig,
}
_, err := c.client.ExecSignal(c.ctx, &req)
if err != nil {
return err
}
return nil
} | go | func (c *HyperClient) ContainerExecSignal(container, execID string, sig int64) error {
req := types.ExecSignalRequest{
ContainerID: container,
ExecID: execID,
Signal: sig,
}
_, err := c.client.ExecSignal(c.ctx, &req)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"c",
"*",
"HyperClient",
")",
"ContainerExecSignal",
"(",
"container",
",",
"execID",
"string",
",",
"sig",
"int64",
")",
"error",
"{",
"req",
":=",
"types",
".",
"ExecSignalRequest",
"{",
"ContainerID",
":",
"container",
",",
"ExecID",
":",
"... | // ContainerExecSignal sends signal to specified exec of specified container | [
"ContainerExecSignal",
"sends",
"signal",
"to",
"specified",
"exec",
"of",
"specified",
"container"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/integration/client.go#L355-L367 |
149,901 | hyperhq/hyperd | integration/client.go | ContainerExecCreate | func (c *HyperClient) ContainerExecCreate(container string, command []string, tty bool) (string, error) {
req := types.ExecCreateRequest{
ContainerID: container,
Command: command,
Tty: tty,
}
resp, err := c.client.ExecCreate(c.ctx, &req)
if err != nil {
return "", err
}
return resp.ExecID, ni... | go | func (c *HyperClient) ContainerExecCreate(container string, command []string, tty bool) (string, error) {
req := types.ExecCreateRequest{
ContainerID: container,
Command: command,
Tty: tty,
}
resp, err := c.client.ExecCreate(c.ctx, &req)
if err != nil {
return "", err
}
return resp.ExecID, ni... | [
"func",
"(",
"c",
"*",
"HyperClient",
")",
"ContainerExecCreate",
"(",
"container",
"string",
",",
"command",
"[",
"]",
"string",
",",
"tty",
"bool",
")",
"(",
"string",
",",
"error",
")",
"{",
"req",
":=",
"types",
".",
"ExecCreateRequest",
"{",
"Contai... | // ContainerExecCreate creates exec in a container | [
"ContainerExecCreate",
"creates",
"exec",
"in",
"a",
"container"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/integration/client.go#L370-L382 |
149,902 | hyperhq/hyperd | integration/client.go | ContainerExecStart | func (c *HyperClient) ContainerExecStart(containerId, execId string, stdin io.ReadCloser, stdout, stderr io.Writer, tty bool) error {
request := types.ExecStartRequest{
ContainerID: containerId,
ExecID: execId,
}
stream, err := c.client.ExecStart(context.Background())
if err != nil {
return err
}
if er... | go | func (c *HyperClient) ContainerExecStart(containerId, execId string, stdin io.ReadCloser, stdout, stderr io.Writer, tty bool) error {
request := types.ExecStartRequest{
ContainerID: containerId,
ExecID: execId,
}
stream, err := c.client.ExecStart(context.Background())
if err != nil {
return err
}
if er... | [
"func",
"(",
"c",
"*",
"HyperClient",
")",
"ContainerExecStart",
"(",
"containerId",
",",
"execId",
"string",
",",
"stdin",
"io",
".",
"ReadCloser",
",",
"stdout",
",",
"stderr",
"io",
".",
"Writer",
",",
"tty",
"bool",
")",
"error",
"{",
"request",
":="... | // ContainerExecStart starts exec in a container with input stream in and output stream out | [
"ContainerExecStart",
"starts",
"exec",
"in",
"a",
"container",
"with",
"input",
"stream",
"in",
"and",
"output",
"stream",
"out"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/integration/client.go#L385-L466 |
149,903 | hyperhq/hyperd | integration/client.go | StartPod | func (c *HyperClient) StartPod(podID string) error {
req := &types.PodStartRequest{
PodID: podID,
}
_, err := c.client.PodStart(c.ctx, req)
if err != nil {
return err
}
return nil
} | go | func (c *HyperClient) StartPod(podID string) error {
req := &types.PodStartRequest{
PodID: podID,
}
_, err := c.client.PodStart(c.ctx, req)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"c",
"*",
"HyperClient",
")",
"StartPod",
"(",
"podID",
"string",
")",
"error",
"{",
"req",
":=",
"&",
"types",
".",
"PodStartRequest",
"{",
"PodID",
":",
"podID",
",",
"}",
"\n\n",
"_",
",",
"err",
":=",
"c",
".",
"client",
".",
"PodS... | // StartPod starts a pod by podID | [
"StartPod",
"starts",
"a",
"pod",
"by",
"podID"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/integration/client.go#L469-L480 |
149,904 | hyperhq/hyperd | integration/client.go | StopPod | func (c *HyperClient) StopPod(podID string) (int, string, error) {
resp, err := c.client.PodStop(c.ctx, &types.PodStopRequest{
PodID: podID,
})
if err != nil {
return -1, "", err
}
return int(resp.Code), resp.Cause, nil
} | go | func (c *HyperClient) StopPod(podID string) (int, string, error) {
resp, err := c.client.PodStop(c.ctx, &types.PodStopRequest{
PodID: podID,
})
if err != nil {
return -1, "", err
}
return int(resp.Code), resp.Cause, nil
} | [
"func",
"(",
"c",
"*",
"HyperClient",
")",
"StopPod",
"(",
"podID",
"string",
")",
"(",
"int",
",",
"string",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"c",
".",
"client",
".",
"PodStop",
"(",
"c",
".",
"ctx",
",",
"&",
"types",
".",
"P... | // StopPod stops a pod | [
"StopPod",
"stops",
"a",
"pod"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/integration/client.go#L483-L492 |
149,905 | hyperhq/hyperd | integration/client.go | PausePod | func (c *HyperClient) PausePod(podID string) error {
_, err := c.client.PodPause(c.ctx, &types.PodPauseRequest{
PodID: podID,
})
if err != nil {
return err
}
return nil
} | go | func (c *HyperClient) PausePod(podID string) error {
_, err := c.client.PodPause(c.ctx, &types.PodPauseRequest{
PodID: podID,
})
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"c",
"*",
"HyperClient",
")",
"PausePod",
"(",
"podID",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
".",
"client",
".",
"PodPause",
"(",
"c",
".",
"ctx",
",",
"&",
"types",
".",
"PodPauseRequest",
"{",
"PodID",
":",
"podID... | // PausePod pauses a pod | [
"PausePod",
"pauses",
"a",
"pod"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/integration/client.go#L495-L504 |
149,906 | hyperhq/hyperd | integration/client.go | UnpausePod | func (c *HyperClient) UnpausePod(podID string) error {
_, err := c.client.PodUnpause(c.ctx, &types.PodUnpauseRequest{
PodID: podID,
})
if err != nil {
return err
}
return nil
} | go | func (c *HyperClient) UnpausePod(podID string) error {
_, err := c.client.PodUnpause(c.ctx, &types.PodUnpauseRequest{
PodID: podID,
})
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"c",
"*",
"HyperClient",
")",
"UnpausePod",
"(",
"podID",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
".",
"client",
".",
"PodUnpause",
"(",
"c",
".",
"ctx",
",",
"&",
"types",
".",
"PodUnpauseRequest",
"{",
"PodID",
":",
... | // UnpausePod unpauses a pod | [
"UnpausePod",
"unpauses",
"a",
"pod"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/integration/client.go#L507-L516 |
149,907 | hyperhq/hyperd | integration/client.go | PodSignal | func (c *HyperClient) PodSignal(podID string, signal int64) error {
_, err := c.client.PodSignal(c.ctx, &types.PodSignalRequest{
PodID: podID,
Signal: signal,
})
if err != nil {
return err
}
return nil
} | go | func (c *HyperClient) PodSignal(podID string, signal int64) error {
_, err := c.client.PodSignal(c.ctx, &types.PodSignalRequest{
PodID: podID,
Signal: signal,
})
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"c",
"*",
"HyperClient",
")",
"PodSignal",
"(",
"podID",
"string",
",",
"signal",
"int64",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
".",
"client",
".",
"PodSignal",
"(",
"c",
".",
"ctx",
",",
"&",
"types",
".",
"PodSignalRequest",
... | // PodSignal sends a signal to all containers of specified pod | [
"PodSignal",
"sends",
"a",
"signal",
"to",
"all",
"containers",
"of",
"specified",
"pod"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/integration/client.go#L519-L529 |
149,908 | hyperhq/hyperd | integration/client.go | DeleteService | func (c *HyperClient) DeleteService(podID string, services []*types.UserService) error {
_, err := c.client.ServiceDelete(
c.ctx,
&types.ServiceDelRequest{PodID: podID, Services: services},
)
if err != nil {
return err
}
return nil
} | go | func (c *HyperClient) DeleteService(podID string, services []*types.UserService) error {
_, err := c.client.ServiceDelete(
c.ctx,
&types.ServiceDelRequest{PodID: podID, Services: services},
)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"c",
"*",
"HyperClient",
")",
"DeleteService",
"(",
"podID",
"string",
",",
"services",
"[",
"]",
"*",
"types",
".",
"UserService",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
".",
"client",
".",
"ServiceDelete",
"(",
"c",
".",
"ctx",... | // DeleteService deletes user service by podID and service content | [
"DeleteService",
"deletes",
"user",
"service",
"by",
"podID",
"and",
"service",
"content"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/integration/client.go#L620-L630 |
149,909 | hyperhq/hyperd | integration/client.go | ListService | func (c *HyperClient) ListService(podID string) ([]*types.UserService, error) {
resp, err := c.client.ServiceList(
c.ctx,
&types.ServiceListRequest{PodID: podID},
)
if err != nil {
return nil, err
}
return resp.Services, nil
} | go | func (c *HyperClient) ListService(podID string) ([]*types.UserService, error) {
resp, err := c.client.ServiceList(
c.ctx,
&types.ServiceListRequest{PodID: podID},
)
if err != nil {
return nil, err
}
return resp.Services, nil
} | [
"func",
"(",
"c",
"*",
"HyperClient",
")",
"ListService",
"(",
"podID",
"string",
")",
"(",
"[",
"]",
"*",
"types",
".",
"UserService",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"c",
".",
"client",
".",
"ServiceList",
"(",
"c",
".",
"ctx",
... | // ListService lists user services by podID | [
"ListService",
"lists",
"user",
"services",
"by",
"podID"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/integration/client.go#L633-L644 |
149,910 | hyperhq/hyperd | integration/client.go | GetPodStats | func (c *HyperClient) GetPodStats(podID string) (*types.PodStats, error) {
statsResponse, err := c.client.PodStats(
c.ctx,
&types.PodStatsRequest{PodID: podID},
)
if err != nil {
return nil, err
}
return statsResponse.PodStats, nil
} | go | func (c *HyperClient) GetPodStats(podID string) (*types.PodStats, error) {
statsResponse, err := c.client.PodStats(
c.ctx,
&types.PodStatsRequest{PodID: podID},
)
if err != nil {
return nil, err
}
return statsResponse.PodStats, nil
} | [
"func",
"(",
"c",
"*",
"HyperClient",
")",
"GetPodStats",
"(",
"podID",
"string",
")",
"(",
"*",
"types",
".",
"PodStats",
",",
"error",
")",
"{",
"statsResponse",
",",
"err",
":=",
"c",
".",
"client",
".",
"PodStats",
"(",
"c",
".",
"ctx",
",",
"&... | // GetPodStats get stats of Pod by podID | [
"GetPodStats",
"get",
"stats",
"of",
"Pod",
"by",
"podID"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/integration/client.go#L647-L658 |
149,911 | hyperhq/hyperd | integration/client.go | AddService | func (c *HyperClient) AddService(podID string, services []*types.UserService) error {
_, err := c.client.ServiceAdd(
c.ctx,
&types.ServiceAddRequest{PodID: podID, Services: services},
)
if err != nil {
return err
}
return nil
} | go | func (c *HyperClient) AddService(podID string, services []*types.UserService) error {
_, err := c.client.ServiceAdd(
c.ctx,
&types.ServiceAddRequest{PodID: podID, Services: services},
)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"c",
"*",
"HyperClient",
")",
"AddService",
"(",
"podID",
"string",
",",
"services",
"[",
"]",
"*",
"types",
".",
"UserService",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
".",
"client",
".",
"ServiceAdd",
"(",
"c",
".",
"ctx",
","... | // AddService adds user service by podID and service content | [
"AddService",
"adds",
"user",
"service",
"by",
"podID",
"and",
"service",
"content"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/integration/client.go#L661-L672 |
149,912 | hyperhq/hyperd | integration/client.go | UpdateService | func (c *HyperClient) UpdateService(podID string, services []*types.UserService) error {
_, err := c.client.ServiceUpdate(
c.ctx,
&types.ServiceUpdateRequest{PodID: podID, Services: services},
)
if err != nil {
return err
}
return nil
} | go | func (c *HyperClient) UpdateService(podID string, services []*types.UserService) error {
_, err := c.client.ServiceUpdate(
c.ctx,
&types.ServiceUpdateRequest{PodID: podID, Services: services},
)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"c",
"*",
"HyperClient",
")",
"UpdateService",
"(",
"podID",
"string",
",",
"services",
"[",
"]",
"*",
"types",
".",
"UserService",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
".",
"client",
".",
"ServiceUpdate",
"(",
"c",
".",
"ctx",... | // UpdateService updates user service by podID and service content | [
"UpdateService",
"updates",
"user",
"service",
"by",
"podID",
"and",
"service",
"content"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/integration/client.go#L675-L685 |
149,913 | hyperhq/hyperd | integration/client.go | SetPodLabels | func (c *HyperClient) SetPodLabels(podID string, override bool, labels map[string]string) error {
_, err := c.client.SetPodLabels(
c.ctx,
&types.PodLabelsRequest{PodID: podID, Override: override, Labels: labels},
)
if err != nil {
return err
}
return nil
} | go | func (c *HyperClient) SetPodLabels(podID string, override bool, labels map[string]string) error {
_, err := c.client.SetPodLabels(
c.ctx,
&types.PodLabelsRequest{PodID: podID, Override: override, Labels: labels},
)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"c",
"*",
"HyperClient",
")",
"SetPodLabels",
"(",
"podID",
"string",
",",
"override",
"bool",
",",
"labels",
"map",
"[",
"string",
"]",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
".",
"client",
".",
"SetPodLabels",
"(",
"c... | // SetPodLabels sets labels to Pod by podID | [
"SetPodLabels",
"sets",
"labels",
"to",
"Pod",
"by",
"podID"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/integration/client.go#L688-L699 |
149,914 | hyperhq/hyperd | integration/client.go | Info | func (c *HyperClient) Info() (*types.InfoResponse, error) {
info, err := c.client.Info(
c.ctx,
&types.InfoRequest{},
)
if err != nil {
return nil, err
}
return info, nil
} | go | func (c *HyperClient) Info() (*types.InfoResponse, error) {
info, err := c.client.Info(
c.ctx,
&types.InfoRequest{},
)
if err != nil {
return nil, err
}
return info, nil
} | [
"func",
"(",
"c",
"*",
"HyperClient",
")",
"Info",
"(",
")",
"(",
"*",
"types",
".",
"InfoResponse",
",",
"error",
")",
"{",
"info",
",",
"err",
":=",
"c",
".",
"client",
".",
"Info",
"(",
"c",
".",
"ctx",
",",
"&",
"types",
".",
"InfoRequest",
... | // Info gets system info of hyperd | [
"Info",
"gets",
"system",
"info",
"of",
"hyperd"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/integration/client.go#L702-L713 |
149,915 | hyperhq/hyperd | integration/client.go | ContainerSignal | func (c *HyperClient) ContainerSignal(podID, containerID string, signal int64) error {
_, err := c.client.ContainerSignal(c.ctx, &types.ContainerSignalRequest{
PodID: podID,
ContainerID: containerID,
Signal: signal,
})
return err
} | go | func (c *HyperClient) ContainerSignal(podID, containerID string, signal int64) error {
_, err := c.client.ContainerSignal(c.ctx, &types.ContainerSignalRequest{
PodID: podID,
ContainerID: containerID,
Signal: signal,
})
return err
} | [
"func",
"(",
"c",
"*",
"HyperClient",
")",
"ContainerSignal",
"(",
"podID",
",",
"containerID",
"string",
",",
"signal",
"int64",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
".",
"client",
".",
"ContainerSignal",
"(",
"c",
".",
"ctx",
",",
"&",
"t... | // ContainerSignal sends a signal to specified container of specified pod | [
"ContainerSignal",
"sends",
"a",
"signal",
"to",
"specified",
"container",
"of",
"specified",
"pod"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/integration/client.go#L730-L738 |
149,916 | hyperhq/hyperd | daemon/pod/decommission.go | cleanup | func (p *XPod) cleanup() {
//if removing, the remove will get the resourceLock in advance, and it will set
// the pod status to NONE when it complete.
// Therefore, if get into cleanup() after remove, cleanup should exit when it
// got a
p.resourceLock.Lock()
defer p.resourceLock.Unlock()
p.statusLock.Lock()
i... | go | func (p *XPod) cleanup() {
//if removing, the remove will get the resourceLock in advance, and it will set
// the pod status to NONE when it complete.
// Therefore, if get into cleanup() after remove, cleanup should exit when it
// got a
p.resourceLock.Lock()
defer p.resourceLock.Unlock()
p.statusLock.Lock()
i... | [
"func",
"(",
"p",
"*",
"XPod",
")",
"cleanup",
"(",
")",
"{",
"//if removing, the remove will get the resourceLock in advance, and it will set",
"// the pod status to NONE when it complete.",
"// Therefore, if get into cleanup() after remove, cleanup should exit when it",
"// got a",
"p"... | //cleanup is used to cleanup the resource after VM shutdown. This method should only called by waitVMStop | [
"cleanup",
"is",
"used",
"to",
"cleanup",
"the",
"resource",
"after",
"VM",
"shutdown",
".",
"This",
"method",
"should",
"only",
"called",
"by",
"waitVMStop"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/daemon/pod/decommission.go#L542-L584 |
149,917 | hyperhq/hyperd | client/client.go | Cmd | func (cli *HyperClient) Cmd(args ...string) error {
if len(args) > 1 {
method, exists := cli.getMethod(args[:2]...)
if exists {
return method(args[2:]...)
}
}
if len(args) > 0 {
method, exists := cli.getMethod(args[0])
if !exists {
fmt.Printf("%s: '%s' is not a %s command. See '%s --help'.\n", os.Arg... | go | func (cli *HyperClient) Cmd(args ...string) error {
if len(args) > 1 {
method, exists := cli.getMethod(args[:2]...)
if exists {
return method(args[2:]...)
}
}
if len(args) > 0 {
method, exists := cli.getMethod(args[0])
if !exists {
fmt.Printf("%s: '%s' is not a %s command. See '%s --help'.\n", os.Arg... | [
"func",
"(",
"cli",
"*",
"HyperClient",
")",
"Cmd",
"(",
"args",
"...",
"string",
")",
"error",
"{",
"if",
"len",
"(",
"args",
")",
">",
"1",
"{",
"method",
",",
"exists",
":=",
"cli",
".",
"getMethod",
"(",
"args",
"[",
":",
"2",
"]",
"...",
"... | // Cmd executes the specified command. | [
"Cmd",
"executes",
"the",
"specified",
"command",
"."
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/client/client.go#L86-L102 |
149,918 | hyperhq/hyperd | utils/utils.go | FormatMountLabel | func FormatMountLabel(src, mountLabel string) string {
if mountLabel != "" {
switch src {
case "":
src = fmt.Sprintf("context=%q", mountLabel)
default:
src = fmt.Sprintf("%s,context=%q", src, mountLabel)
}
}
return src
} | go | func FormatMountLabel(src, mountLabel string) string {
if mountLabel != "" {
switch src {
case "":
src = fmt.Sprintf("context=%q", mountLabel)
default:
src = fmt.Sprintf("%s,context=%q", src, mountLabel)
}
}
return src
} | [
"func",
"FormatMountLabel",
"(",
"src",
",",
"mountLabel",
"string",
")",
"string",
"{",
"if",
"mountLabel",
"!=",
"\"",
"\"",
"{",
"switch",
"src",
"{",
"case",
"\"",
"\"",
":",
"src",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"mountLabel",
... | // FormatMountLabel returns a string to be used by the mount command.
// The format of this string will be used to alter the labeling of the mountpoint.
// The string returned is suitable to be used as the options field of the mount command.
// If you need to have additional mount point options, you can pass them in as... | [
"FormatMountLabel",
"returns",
"a",
"string",
"to",
"be",
"used",
"by",
"the",
"mount",
"command",
".",
"The",
"format",
"of",
"this",
"string",
"will",
"be",
"used",
"to",
"alter",
"the",
"labeling",
"of",
"the",
"mountpoint",
".",
"The",
"string",
"retur... | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/utils/utils.go#L72-L82 |
149,919 | hyperhq/hyperd | serverrpc/info.go | PodInfo | func (s *ServerRPC) PodInfo(c context.Context, req *types.PodInfoRequest) (*types.PodInfoResponse, error) {
info, err := s.daemon.GetPodInfo(req.PodID)
if err != nil {
return nil, err
}
return &types.PodInfoResponse{
PodInfo: info,
}, nil
} | go | func (s *ServerRPC) PodInfo(c context.Context, req *types.PodInfoRequest) (*types.PodInfoResponse, error) {
info, err := s.daemon.GetPodInfo(req.PodID)
if err != nil {
return nil, err
}
return &types.PodInfoResponse{
PodInfo: info,
}, nil
} | [
"func",
"(",
"s",
"*",
"ServerRPC",
")",
"PodInfo",
"(",
"c",
"context",
".",
"Context",
",",
"req",
"*",
"types",
".",
"PodInfoRequest",
")",
"(",
"*",
"types",
".",
"PodInfoResponse",
",",
"error",
")",
"{",
"info",
",",
"err",
":=",
"s",
".",
"d... | // PodInfo gets PodInfo by podID | [
"PodInfo",
"gets",
"PodInfo",
"by",
"podID"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/serverrpc/info.go#L14-L23 |
149,920 | hyperhq/hyperd | serverrpc/info.go | ContainerInfo | func (s *ServerRPC) ContainerInfo(c context.Context, req *types.ContainerInfoRequest) (*types.ContainerInfoResponse, error) {
info, err := s.daemon.GetContainerInfo(req.Container)
if err != nil {
return nil, err
}
return &types.ContainerInfoResponse{
ContainerInfo: info,
}, nil
} | go | func (s *ServerRPC) ContainerInfo(c context.Context, req *types.ContainerInfoRequest) (*types.ContainerInfoResponse, error) {
info, err := s.daemon.GetContainerInfo(req.Container)
if err != nil {
return nil, err
}
return &types.ContainerInfoResponse{
ContainerInfo: info,
}, nil
} | [
"func",
"(",
"s",
"*",
"ServerRPC",
")",
"ContainerInfo",
"(",
"c",
"context",
".",
"Context",
",",
"req",
"*",
"types",
".",
"ContainerInfoRequest",
")",
"(",
"*",
"types",
".",
"ContainerInfoResponse",
",",
"error",
")",
"{",
"info",
",",
"err",
":=",
... | // ContainerInfo gets ContainerInfo by ID or name of container | [
"ContainerInfo",
"gets",
"ContainerInfo",
"by",
"ID",
"or",
"name",
"of",
"container"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/serverrpc/info.go#L26-L35 |
149,921 | hyperhq/hyperd | serverrpc/info.go | Info | func (s *ServerRPC) Info(c context.Context, req *types.InfoRequest) (*types.InfoResponse, error) {
info, err := s.daemon.CmdSystemInfo()
if err != nil {
return nil, err
}
return info, nil
} | go | func (s *ServerRPC) Info(c context.Context, req *types.InfoRequest) (*types.InfoResponse, error) {
info, err := s.daemon.CmdSystemInfo()
if err != nil {
return nil, err
}
return info, nil
} | [
"func",
"(",
"s",
"*",
"ServerRPC",
")",
"Info",
"(",
"c",
"context",
".",
"Context",
",",
"req",
"*",
"types",
".",
"InfoRequest",
")",
"(",
"*",
"types",
".",
"InfoResponse",
",",
"error",
")",
"{",
"info",
",",
"err",
":=",
"s",
".",
"daemon",
... | // Info gets CmdSystemInfo | [
"Info",
"gets",
"CmdSystemInfo"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/serverrpc/info.go#L38-L45 |
149,922 | hyperhq/hyperd | serverrpc/info.go | Version | func (s *ServerRPC) Version(c context.Context, req *types.VersionRequest) (*types.VersionResponse, error) {
return &types.VersionResponse{
Version: utils.VERSION,
ApiVersion: GRPC_API_VERSION,
}, nil
} | go | func (s *ServerRPC) Version(c context.Context, req *types.VersionRequest) (*types.VersionResponse, error) {
return &types.VersionResponse{
Version: utils.VERSION,
ApiVersion: GRPC_API_VERSION,
}, nil
} | [
"func",
"(",
"s",
"*",
"ServerRPC",
")",
"Version",
"(",
"c",
"context",
".",
"Context",
",",
"req",
"*",
"types",
".",
"VersionRequest",
")",
"(",
"*",
"types",
".",
"VersionResponse",
",",
"error",
")",
"{",
"return",
"&",
"types",
".",
"VersionRespo... | // Version gets the version and apiVersion of hyperd | [
"Version",
"gets",
"the",
"version",
"and",
"apiVersion",
"of",
"hyperd"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/serverrpc/info.go#L48-L53 |
149,923 | hyperhq/hyperd | serverrpc/container.go | ContainerCreate | func (s *ServerRPC) ContainerCreate(ctx context.Context, req *types.ContainerCreateRequest) (*types.ContainerCreateResponse, error) {
containerID, err := s.daemon.CreateContainerInPod(req.PodID, req.ContainerSpec)
if err != nil {
return nil, err
}
return &types.ContainerCreateResponse{
ContainerID: containerID... | go | func (s *ServerRPC) ContainerCreate(ctx context.Context, req *types.ContainerCreateRequest) (*types.ContainerCreateResponse, error) {
containerID, err := s.daemon.CreateContainerInPod(req.PodID, req.ContainerSpec)
if err != nil {
return nil, err
}
return &types.ContainerCreateResponse{
ContainerID: containerID... | [
"func",
"(",
"s",
"*",
"ServerRPC",
")",
"ContainerCreate",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"types",
".",
"ContainerCreateRequest",
")",
"(",
"*",
"types",
".",
"ContainerCreateResponse",
",",
"error",
")",
"{",
"containerID",
",",
... | // ContainerCreate creates a container by UserContainer spec | [
"ContainerCreate",
"creates",
"a",
"container",
"by",
"UserContainer",
"spec"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/serverrpc/container.go#L9-L18 |
149,924 | hyperhq/hyperd | serverrpc/container.go | ContainerRename | func (s *ServerRPC) ContainerRename(c context.Context, req *types.ContainerRenameRequest) (*types.ContainerRenameResponse, error) {
err := s.daemon.ContainerRename(req.OldContainerName, req.NewContainerName)
if err != nil {
return nil, err
}
return &types.ContainerRenameResponse{}, nil
} | go | func (s *ServerRPC) ContainerRename(c context.Context, req *types.ContainerRenameRequest) (*types.ContainerRenameResponse, error) {
err := s.daemon.ContainerRename(req.OldContainerName, req.NewContainerName)
if err != nil {
return nil, err
}
return &types.ContainerRenameResponse{}, nil
} | [
"func",
"(",
"s",
"*",
"ServerRPC",
")",
"ContainerRename",
"(",
"c",
"context",
".",
"Context",
",",
"req",
"*",
"types",
".",
"ContainerRenameRequest",
")",
"(",
"*",
"types",
".",
"ContainerRenameResponse",
",",
"error",
")",
"{",
"err",
":=",
"s",
".... | // ContainerRename rename a container | [
"ContainerRename",
"rename",
"a",
"container"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/serverrpc/container.go#L40-L47 |
149,925 | hyperhq/hyperd | serverrpc/container.go | ContainerSignal | func (s *ServerRPC) ContainerSignal(ctx context.Context, req *types.ContainerSignalRequest) (*types.ContainerSignalResponse, error) {
err := s.daemon.KillPodContainers(req.PodID, req.ContainerID, req.Signal)
if err != nil {
return nil, err
}
return &types.ContainerSignalResponse{}, nil
} | go | func (s *ServerRPC) ContainerSignal(ctx context.Context, req *types.ContainerSignalRequest) (*types.ContainerSignalResponse, error) {
err := s.daemon.KillPodContainers(req.PodID, req.ContainerID, req.Signal)
if err != nil {
return nil, err
}
return &types.ContainerSignalResponse{}, nil
} | [
"func",
"(",
"s",
"*",
"ServerRPC",
")",
"ContainerSignal",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"types",
".",
"ContainerSignalRequest",
")",
"(",
"*",
"types",
".",
"ContainerSignalResponse",
",",
"error",
")",
"{",
"err",
":=",
"s",
... | // ContainerSignal sends a singal to specified container of specified pod | [
"ContainerSignal",
"sends",
"a",
"singal",
"to",
"specified",
"container",
"of",
"specified",
"pod"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/serverrpc/container.go#L59-L66 |
149,926 | hyperhq/hyperd | daemon/daemonbuilder/builder.go | Pull | func (d Docker) Pull(name string) (builder.Image, error) {
ref, err := reference.ParseNamed(name)
if err != nil {
return nil, err
}
ref = reference.WithDefaultTag(ref)
pullRegistryAuth := &types.AuthConfig{}
if len(d.AuthConfigs) > 0 {
// The request came with a full auth config file, we prefer to use that
... | go | func (d Docker) Pull(name string) (builder.Image, error) {
ref, err := reference.ParseNamed(name)
if err != nil {
return nil, err
}
ref = reference.WithDefaultTag(ref)
pullRegistryAuth := &types.AuthConfig{}
if len(d.AuthConfigs) > 0 {
// The request came with a full auth config file, we prefer to use that
... | [
"func",
"(",
"d",
"Docker",
")",
"Pull",
"(",
"name",
"string",
")",
"(",
"builder",
".",
"Image",
",",
"error",
")",
"{",
"ref",
",",
"err",
":=",
"reference",
".",
"ParseNamed",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"... | // Pull tells Docker to pull image referenced by `name`. | [
"Pull",
"tells",
"Docker",
"to",
"pull",
"image",
"referenced",
"by",
"name",
"."
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/daemon/daemonbuilder/builder.go#L49-L75 |
149,927 | hyperhq/hyperd | daemon/daemonbuilder/builder.go | GetImage | func (d Docker) GetImage(name string) (builder.Image, error) {
img, err := d.Daemon.GetImage(name)
if err != nil {
return nil, err
}
return imgWrap{img}, nil
} | go | func (d Docker) GetImage(name string) (builder.Image, error) {
img, err := d.Daemon.GetImage(name)
if err != nil {
return nil, err
}
return imgWrap{img}, nil
} | [
"func",
"(",
"d",
"Docker",
")",
"GetImage",
"(",
"name",
"string",
")",
"(",
"builder",
".",
"Image",
",",
"error",
")",
"{",
"img",
",",
"err",
":=",
"d",
".",
"Daemon",
".",
"GetImage",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // GetImage looks up a Docker image referenced by `name`. | [
"GetImage",
"looks",
"up",
"a",
"Docker",
"image",
"referenced",
"by",
"name",
"."
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/daemon/daemonbuilder/builder.go#L78-L84 |
149,928 | hyperhq/hyperd | daemon/daemonbuilder/builder.go | ContainerUpdateCmd | func (d Docker) ContainerUpdateCmd(cID string, cmd []string) error {
c, err := d.Daemon.GetContainer(cID)
if err != nil {
return err
}
c.Path = cmd[0]
c.Args = cmd[1:]
return nil
} | go | func (d Docker) ContainerUpdateCmd(cID string, cmd []string) error {
c, err := d.Daemon.GetContainer(cID)
if err != nil {
return err
}
c.Path = cmd[0]
c.Args = cmd[1:]
return nil
} | [
"func",
"(",
"d",
"Docker",
")",
"ContainerUpdateCmd",
"(",
"cID",
"string",
",",
"cmd",
"[",
"]",
"string",
")",
"error",
"{",
"c",
",",
"err",
":=",
"d",
".",
"Daemon",
".",
"GetContainer",
"(",
"cID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // ContainerUpdateCmd updates Path and Args for the container with ID cID. | [
"ContainerUpdateCmd",
"updates",
"Path",
"and",
"Args",
"for",
"the",
"container",
"with",
"ID",
"cID",
"."
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/daemon/daemonbuilder/builder.go#L87-L95 |
149,929 | hyperhq/hyperd | daemon/daemonbuilder/builder.go | GetCachedImage | func (d Docker) GetCachedImage(imgID string, cfg *container.Config) (string, error) {
cache, err := d.Daemon.ImageGetCached(image.ID(imgID), cfg)
if cache == nil || err != nil {
return "", err
}
return cache.ID().String(), nil
} | go | func (d Docker) GetCachedImage(imgID string, cfg *container.Config) (string, error) {
cache, err := d.Daemon.ImageGetCached(image.ID(imgID), cfg)
if cache == nil || err != nil {
return "", err
}
return cache.ID().String(), nil
} | [
"func",
"(",
"d",
"Docker",
")",
"GetCachedImage",
"(",
"imgID",
"string",
",",
"cfg",
"*",
"container",
".",
"Config",
")",
"(",
"string",
",",
"error",
")",
"{",
"cache",
",",
"err",
":=",
"d",
".",
"Daemon",
".",
"ImageGetCached",
"(",
"image",
".... | // GetCachedImage returns a reference to a cached image whose parent equals `parent`
// and runconfig equals `cfg`. A cache miss is expected to return an empty ID and a nil error. | [
"GetCachedImage",
"returns",
"a",
"reference",
"to",
"a",
"cached",
"image",
"whose",
"parent",
"equals",
"parent",
"and",
"runconfig",
"equals",
"cfg",
".",
"A",
"cache",
"miss",
"is",
"expected",
"to",
"return",
"an",
"empty",
"ID",
"and",
"a",
"nil",
"e... | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/daemon/daemonbuilder/builder.go#L99-L105 |
149,930 | hyperhq/hyperd | daemon/pod/migration.go | MigrateLagecyPersistentData | func MigrateLagecyPersistentData(db *daemondb.DaemonDB, podFactory func() *PodFactory) (err error) {
num := 0
count := 0
defer func() {
logInfo := fmt.Sprintf("Migrate lagecy persistent pod data, found: %d, migrated: %d", num, count)
if err == nil {
hlog.Log(INFO, logInfo)
} else {
hlog.Log(ERROR, "%s, b... | go | func MigrateLagecyPersistentData(db *daemondb.DaemonDB, podFactory func() *PodFactory) (err error) {
num := 0
count := 0
defer func() {
logInfo := fmt.Sprintf("Migrate lagecy persistent pod data, found: %d, migrated: %d", num, count)
if err == nil {
hlog.Log(INFO, logInfo)
} else {
hlog.Log(ERROR, "%s, b... | [
"func",
"MigrateLagecyPersistentData",
"(",
"db",
"*",
"daemondb",
".",
"DaemonDB",
",",
"podFactory",
"func",
"(",
")",
"*",
"PodFactory",
")",
"(",
"err",
"error",
")",
"{",
"num",
":=",
"0",
"\n",
"count",
":=",
"0",
"\n",
"defer",
"func",
"(",
")",... | // MigrateLagecyData migrate lagecy persistence data to current layout. | [
"MigrateLagecyData",
"migrate",
"lagecy",
"persistence",
"data",
"to",
"current",
"layout",
"."
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/daemon/pod/migration.go#L17-L101 |
149,931 | hyperhq/hyperd | serverrpc/portmapping.go | PortMappingList | func (s *ServerRPC) PortMappingList(ctx context.Context, req *types.PortMappingListRequest) (*types.PortMappingListResponse, error) {
p, ok := s.daemon.PodList.Get(req.PodID)
if !ok {
return nil, fmt.Errorf("Pod not found")
}
return &types.PortMappingListResponse{
PortMappings: p.ListPortMappings(),
}, nil
} | go | func (s *ServerRPC) PortMappingList(ctx context.Context, req *types.PortMappingListRequest) (*types.PortMappingListResponse, error) {
p, ok := s.daemon.PodList.Get(req.PodID)
if !ok {
return nil, fmt.Errorf("Pod not found")
}
return &types.PortMappingListResponse{
PortMappings: p.ListPortMappings(),
}, nil
} | [
"func",
"(",
"s",
"*",
"ServerRPC",
")",
"PortMappingList",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"types",
".",
"PortMappingListRequest",
")",
"(",
"*",
"types",
".",
"PortMappingListResponse",
",",
"error",
")",
"{",
"p",
",",
"ok",
":... | // PortMappingList get a list of PortMappings | [
"PortMappingList",
"get",
"a",
"list",
"of",
"PortMappings"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/serverrpc/portmapping.go#L10-L19 |
149,932 | hyperhq/hyperd | serverrpc/portmapping.go | PortMappingDel | func (s *ServerRPC) PortMappingDel(ctx context.Context, req *types.PortMappingModifyRequest) (*types.PortMappingModifyResponse, error) {
p, ok := s.daemon.PodList.Get(req.PodID)
if !ok {
return nil, fmt.Errorf("Pod not found")
}
err := p.RemovePortMappingByDest(req.PortMappings)
if err != nil {
return nil, fm... | go | func (s *ServerRPC) PortMappingDel(ctx context.Context, req *types.PortMappingModifyRequest) (*types.PortMappingModifyResponse, error) {
p, ok := s.daemon.PodList.Get(req.PodID)
if !ok {
return nil, fmt.Errorf("Pod not found")
}
err := p.RemovePortMappingByDest(req.PortMappings)
if err != nil {
return nil, fm... | [
"func",
"(",
"s",
"*",
"ServerRPC",
")",
"PortMappingDel",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"types",
".",
"PortMappingModifyRequest",
")",
"(",
"*",
"types",
".",
"PortMappingModifyResponse",
",",
"error",
")",
"{",
"p",
",",
"ok",
... | // PortMappingDel remove a list of PortMapping rules from a Pod | [
"PortMappingDel",
"remove",
"a",
"list",
"of",
"PortMapping",
"rules",
"from",
"a",
"Pod"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/serverrpc/portmapping.go#L37-L49 |
149,933 | hyperhq/hyperd | server/middleware.go | debugRequestMiddleware | func debugRequestMiddleware(handler httputils.APIFunc) httputils.APIFunc {
return func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
glog.V(3).Infof("%s %s", r.Method, r.RequestURI)
if r.Method != "POST" {
return handler(ctx, w, r, vars)
}
if err := httputils.... | go | func debugRequestMiddleware(handler httputils.APIFunc) httputils.APIFunc {
return func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
glog.V(3).Infof("%s %s", r.Method, r.RequestURI)
if r.Method != "POST" {
return handler(ctx, w, r, vars)
}
if err := httputils.... | [
"func",
"debugRequestMiddleware",
"(",
"handler",
"httputils",
".",
"APIFunc",
")",
"httputils",
".",
"APIFunc",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
"... | // debugRequestMiddleware dumps the request to logger | [
"debugRequestMiddleware",
"dumps",
"the",
"request",
"to",
"logger"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/server/middleware.go#L27-L67 |
149,934 | hyperhq/hyperd | server/middleware.go | authorizationMiddleware | func (s *Server) authorizationMiddleware(handler httputils.APIFunc) httputils.APIFunc {
return func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
// FIXME: fill when authN gets in
// User and UserAuthNMethod are taken from AuthN plugins
// Currently tracked in https... | go | func (s *Server) authorizationMiddleware(handler httputils.APIFunc) httputils.APIFunc {
return func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
// FIXME: fill when authN gets in
// User and UserAuthNMethod are taken from AuthN plugins
// Currently tracked in https... | [
"func",
"(",
"s",
"*",
"Server",
")",
"authorizationMiddleware",
"(",
"handler",
"httputils",
".",
"APIFunc",
")",
"httputils",
".",
"APIFunc",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"w",
"http",
".",
"ResponseWriter",
",",
"r",... | // authorizationMiddleware perform authorization on the request. | [
"authorizationMiddleware",
"perform",
"authorization",
"on",
"the",
"request",
"."
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/server/middleware.go#L70-L97 |
149,935 | hyperhq/hyperd | server/middleware.go | userAgentMiddleware | func (s *Server) userAgentMiddleware(handler httputils.APIFunc) httputils.APIFunc {
return func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if strings.Contains(r.Header.Get("User-Agent"), "Docker-Client/") {
dockerVersion := version.Version(s.cfg.Version)
userA... | go | func (s *Server) userAgentMiddleware(handler httputils.APIFunc) httputils.APIFunc {
return func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if strings.Contains(r.Header.Get("User-Agent"), "Docker-Client/") {
dockerVersion := version.Version(s.cfg.Version)
userA... | [
"func",
"(",
"s",
"*",
"Server",
")",
"userAgentMiddleware",
"(",
"handler",
"httputils",
".",
"APIFunc",
")",
"httputils",
".",
"APIFunc",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"... | // userAgentMiddleware checks the User-Agent header looking for a valid docker client spec. | [
"userAgentMiddleware",
"checks",
"the",
"User",
"-",
"Agent",
"header",
"looking",
"for",
"a",
"valid",
"docker",
"client",
"spec",
"."
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/server/middleware.go#L100-L119 |
149,936 | hyperhq/hyperd | server/middleware.go | corsMiddleware | func (s *Server) corsMiddleware(handler httputils.APIFunc) httputils.APIFunc {
return func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
// If "api-cors-header" is not given, but "api-enable-cors" is true, we set cors to "*"
// otherwise, all head values will be passe... | go | func (s *Server) corsMiddleware(handler httputils.APIFunc) httputils.APIFunc {
return func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
// If "api-cors-header" is not given, but "api-enable-cors" is true, we set cors to "*"
// otherwise, all head values will be passe... | [
"func",
"(",
"s",
"*",
"Server",
")",
"corsMiddleware",
"(",
"handler",
"httputils",
".",
"APIFunc",
")",
"httputils",
".",
"APIFunc",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
... | // corsMiddleware sets the CORS header expectations in the server. | [
"corsMiddleware",
"sets",
"the",
"CORS",
"header",
"expectations",
"in",
"the",
"server",
"."
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/server/middleware.go#L122-L136 |
149,937 | hyperhq/hyperd | server/middleware.go | versionMiddleware | func versionMiddleware(handler httputils.APIFunc) httputils.APIFunc {
return func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
apiVersion := version.Version(vars["version"])
if apiVersion == "" {
apiVersion = api.DefaultVersion
}
// FIXME: do not check version... | go | func versionMiddleware(handler httputils.APIFunc) httputils.APIFunc {
return func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
apiVersion := version.Version(vars["version"])
if apiVersion == "" {
apiVersion = api.DefaultVersion
}
// FIXME: do not check version... | [
"func",
"versionMiddleware",
"(",
"handler",
"httputils",
".",
"APIFunc",
")",
"httputils",
".",
"APIFunc",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
... | // versionMiddleware checks the api version requirements before passing the request to the server handler. | [
"versionMiddleware",
"checks",
"the",
"api",
"version",
"requirements",
"before",
"passing",
"the",
"request",
"to",
"the",
"server",
"handler",
"."
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/server/middleware.go#L139-L158 |
149,938 | hyperhq/hyperd | storage/vbox/vbox.go | MountContainerToSharedDir | func MountContainerToSharedDir(containerId, sharedDir, devPrefix string) (string, error) {
devFullName := fmt.Sprintf("%s/vbox/images/%s.vdi", utils.HYPER_ROOT, containerId)
return devFullName, nil
} | go | func MountContainerToSharedDir(containerId, sharedDir, devPrefix string) (string, error) {
devFullName := fmt.Sprintf("%s/vbox/images/%s.vdi", utils.HYPER_ROOT, containerId)
return devFullName, nil
} | [
"func",
"MountContainerToSharedDir",
"(",
"containerId",
",",
"sharedDir",
",",
"devPrefix",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"devFullName",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"utils",
".",
"HYPER_ROOT",
",",
"containerId... | // For device mapper, we do not need to mount the container to sharedDir.
// All of we need to provide the block device name of container. | [
"For",
"device",
"mapper",
"we",
"do",
"not",
"need",
"to",
"mount",
"the",
"container",
"to",
"sharedDir",
".",
"All",
"of",
"we",
"need",
"to",
"provide",
"the",
"block",
"device",
"name",
"of",
"container",
"."
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/storage/vbox/vbox.go#L11-L14 |
149,939 | hyperhq/hyperd | serverrpc/images.go | ImagePull | func (s *ServerRPC) ImagePull(req *types.ImagePullRequest, stream types.PublicAPI_ImagePullServer) error {
authConfig := &enginetypes.AuthConfig{}
if req.Auth != nil {
authConfig = &enginetypes.AuthConfig{
Username: req.Auth.Username,
Password: req.Auth.Password,
Auth: req.Auth.Auth,
... | go | func (s *ServerRPC) ImagePull(req *types.ImagePullRequest, stream types.PublicAPI_ImagePullServer) error {
authConfig := &enginetypes.AuthConfig{}
if req.Auth != nil {
authConfig = &enginetypes.AuthConfig{
Username: req.Auth.Username,
Password: req.Auth.Password,
Auth: req.Auth.Auth,
... | [
"func",
"(",
"s",
"*",
"ServerRPC",
")",
"ImagePull",
"(",
"req",
"*",
"types",
".",
"ImagePullRequest",
",",
"stream",
"types",
".",
"PublicAPI_ImagePullServer",
")",
"error",
"{",
"authConfig",
":=",
"&",
"enginetypes",
".",
"AuthConfig",
"{",
"}",
"\n",
... | // ImagePull pulls a image from registry | [
"ImagePull",
"pulls",
"a",
"image",
"from",
"registry"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/serverrpc/images.go#L41-L92 |
149,940 | hyperhq/hyperd | serverrpc/images.go | ImagePush | func (s *ServerRPC) ImagePush(req *types.ImagePushRequest, stream types.PublicAPI_ImagePushServer) error {
authConfig := &enginetypes.AuthConfig{}
if req.Auth != nil {
authConfig = &enginetypes.AuthConfig{
Username: req.Auth.Username,
Password: req.Auth.Password,
Auth: req.Auth.Auth,
... | go | func (s *ServerRPC) ImagePush(req *types.ImagePushRequest, stream types.PublicAPI_ImagePushServer) error {
authConfig := &enginetypes.AuthConfig{}
if req.Auth != nil {
authConfig = &enginetypes.AuthConfig{
Username: req.Auth.Username,
Password: req.Auth.Password,
Auth: req.Auth.Auth,
... | [
"func",
"(",
"s",
"*",
"ServerRPC",
")",
"ImagePush",
"(",
"req",
"*",
"types",
".",
"ImagePushRequest",
",",
"stream",
"types",
".",
"PublicAPI_ImagePushServer",
")",
"error",
"{",
"authConfig",
":=",
"&",
"enginetypes",
".",
"AuthConfig",
"{",
"}",
"\n",
... | // ImagePush pushes a local image to registry | [
"ImagePush",
"pushes",
"a",
"local",
"image",
"to",
"registry"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/serverrpc/images.go#L95-L140 |
149,941 | hyperhq/hyperd | serverrpc/images.go | ImageRemove | func (s *ServerRPC) ImageRemove(ctx context.Context, req *types.ImageRemoveRequest) (*types.ImageRemoveResponse, error) {
resp, err := s.daemon.CmdImageDelete(req.Image, req.Force, req.Prune)
if err != nil {
return nil, err
}
return &types.ImageRemoveResponse{
Images: resp,
}, nil
} | go | func (s *ServerRPC) ImageRemove(ctx context.Context, req *types.ImageRemoveRequest) (*types.ImageRemoveResponse, error) {
resp, err := s.daemon.CmdImageDelete(req.Image, req.Force, req.Prune)
if err != nil {
return nil, err
}
return &types.ImageRemoveResponse{
Images: resp,
}, nil
} | [
"func",
"(",
"s",
"*",
"ServerRPC",
")",
"ImageRemove",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"types",
".",
"ImageRemoveRequest",
")",
"(",
"*",
"types",
".",
"ImageRemoveResponse",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"s... | // ImageRemove deletes a image from hyperd | [
"ImageRemove",
"deletes",
"a",
"image",
"from",
"hyperd"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/serverrpc/images.go#L143-L152 |
149,942 | hyperhq/hyperd | serverrpc/pod.go | PodCreate | func (s *ServerRPC) PodCreate(ctx context.Context, req *types.PodCreateRequest) (*types.PodCreateResponse, error) {
p, err := s.daemon.CreatePod(req.PodID, req.PodSpec)
if err != nil {
return nil, err
}
return &types.PodCreateResponse{
PodID: p.Id(),
}, nil
} | go | func (s *ServerRPC) PodCreate(ctx context.Context, req *types.PodCreateRequest) (*types.PodCreateResponse, error) {
p, err := s.daemon.CreatePod(req.PodID, req.PodSpec)
if err != nil {
return nil, err
}
return &types.PodCreateResponse{
PodID: p.Id(),
}, nil
} | [
"func",
"(",
"s",
"*",
"ServerRPC",
")",
"PodCreate",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"types",
".",
"PodCreateRequest",
")",
"(",
"*",
"types",
".",
"PodCreateResponse",
",",
"error",
")",
"{",
"p",
",",
"err",
":=",
"s",
".",... | // PodCreate creates a pod by PodSpec | [
"PodCreate",
"creates",
"a",
"pod",
"by",
"PodSpec"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/serverrpc/pod.go#L12-L21 |
149,943 | hyperhq/hyperd | serverrpc/pod.go | PodStart | func (s *ServerRPC) PodStart(ctx context.Context, req *types.PodStartRequest) (*types.PodStartResponse, error) {
err := s.daemon.StartPod(req.PodID)
if err != nil {
return nil, err
}
return &types.PodStartResponse{}, nil
} | go | func (s *ServerRPC) PodStart(ctx context.Context, req *types.PodStartRequest) (*types.PodStartResponse, error) {
err := s.daemon.StartPod(req.PodID)
if err != nil {
return nil, err
}
return &types.PodStartResponse{}, nil
} | [
"func",
"(",
"s",
"*",
"ServerRPC",
")",
"PodStart",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"types",
".",
"PodStartRequest",
")",
"(",
"*",
"types",
".",
"PodStartResponse",
",",
"error",
")",
"{",
"err",
":=",
"s",
".",
"daemon",
".... | // PodStart starts a pod by podID | [
"PodStart",
"starts",
"a",
"pod",
"by",
"podID"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/serverrpc/pod.go#L24-L31 |
149,944 | hyperhq/hyperd | serverrpc/pod.go | PodRemove | func (s *ServerRPC) PodRemove(ctx context.Context, req *types.PodRemoveRequest) (*types.PodRemoveResponse, error) {
if req.PodID == "" {
return nil, fmt.Errorf("PodRemove failed PodID is required for PodRemove")
}
code, cause, err := s.daemon.RemovePod(req.PodID)
if err != nil {
return nil, fmt.Errorf("s.daemo... | go | func (s *ServerRPC) PodRemove(ctx context.Context, req *types.PodRemoveRequest) (*types.PodRemoveResponse, error) {
if req.PodID == "" {
return nil, fmt.Errorf("PodRemove failed PodID is required for PodRemove")
}
code, cause, err := s.daemon.RemovePod(req.PodID)
if err != nil {
return nil, fmt.Errorf("s.daemo... | [
"func",
"(",
"s",
"*",
"ServerRPC",
")",
"PodRemove",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"types",
".",
"PodRemoveRequest",
")",
"(",
"*",
"types",
".",
"PodRemoveResponse",
",",
"error",
")",
"{",
"if",
"req",
".",
"PodID",
"==",
... | // PodRemove removes a pod by podID | [
"PodRemove",
"removes",
"a",
"pod",
"by",
"podID"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/serverrpc/pod.go#L34-L48 |
149,945 | hyperhq/hyperd | serverrpc/pod.go | PodStop | func (s *ServerRPC) PodStop(ctx context.Context, req *types.PodStopRequest) (*types.PodStopResponse, error) {
code, cause, err := s.daemon.StopPod(req.PodID)
if err != nil {
return nil, err
}
return &types.PodStopResponse{
Cause: cause,
Code: int32(code),
}, nil
} | go | func (s *ServerRPC) PodStop(ctx context.Context, req *types.PodStopRequest) (*types.PodStopResponse, error) {
code, cause, err := s.daemon.StopPod(req.PodID)
if err != nil {
return nil, err
}
return &types.PodStopResponse{
Cause: cause,
Code: int32(code),
}, nil
} | [
"func",
"(",
"s",
"*",
"ServerRPC",
")",
"PodStop",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"types",
".",
"PodStopRequest",
")",
"(",
"*",
"types",
".",
"PodStopResponse",
",",
"error",
")",
"{",
"code",
",",
"cause",
",",
"err",
":="... | // PodStop stops a pod | [
"PodStop",
"stops",
"a",
"pod"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/serverrpc/pod.go#L51-L61 |
149,946 | hyperhq/hyperd | serverrpc/pod.go | PodSignal | func (s *ServerRPC) PodSignal(ctx context.Context, req *types.PodSignalRequest) (*types.PodSignalResponse, error) {
err := s.daemon.KillPodContainers(req.PodID, "", req.Signal)
if err != nil {
return nil, err
}
return &types.PodSignalResponse{}, nil
} | go | func (s *ServerRPC) PodSignal(ctx context.Context, req *types.PodSignalRequest) (*types.PodSignalResponse, error) {
err := s.daemon.KillPodContainers(req.PodID, "", req.Signal)
if err != nil {
return nil, err
}
return &types.PodSignalResponse{}, nil
} | [
"func",
"(",
"s",
"*",
"ServerRPC",
")",
"PodSignal",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"types",
".",
"PodSignalRequest",
")",
"(",
"*",
"types",
".",
"PodSignalResponse",
",",
"error",
")",
"{",
"err",
":=",
"s",
".",
"daemon",
... | // PodSignal sends a singal to all containers of specified pod | [
"PodSignal",
"sends",
"a",
"singal",
"to",
"all",
"containers",
"of",
"specified",
"pod"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/serverrpc/pod.go#L64-L71 |
149,947 | hyperhq/hyperd | serverrpc/pod.go | PodPause | func (s *ServerRPC) PodPause(ctx context.Context, req *types.PodPauseRequest) (*types.PodPauseResponse, error) {
err := s.daemon.PausePod(req.PodID)
if err != nil {
return nil, err
}
return &types.PodPauseResponse{}, nil
} | go | func (s *ServerRPC) PodPause(ctx context.Context, req *types.PodPauseRequest) (*types.PodPauseResponse, error) {
err := s.daemon.PausePod(req.PodID)
if err != nil {
return nil, err
}
return &types.PodPauseResponse{}, nil
} | [
"func",
"(",
"s",
"*",
"ServerRPC",
")",
"PodPause",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"types",
".",
"PodPauseRequest",
")",
"(",
"*",
"types",
".",
"PodPauseResponse",
",",
"error",
")",
"{",
"err",
":=",
"s",
".",
"daemon",
".... | // PodPause pauses a pod | [
"PodPause",
"pauses",
"a",
"pod"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/serverrpc/pod.go#L74-L81 |
149,948 | hyperhq/hyperd | serverrpc/pod.go | PodUnpause | func (s *ServerRPC) PodUnpause(ctx context.Context, req *types.PodUnpauseRequest) (*types.PodUnpauseResponse, error) {
err := s.daemon.UnpausePod(req.PodID)
if err != nil {
return nil, err
}
return &types.PodUnpauseResponse{}, nil
} | go | func (s *ServerRPC) PodUnpause(ctx context.Context, req *types.PodUnpauseRequest) (*types.PodUnpauseResponse, error) {
err := s.daemon.UnpausePod(req.PodID)
if err != nil {
return nil, err
}
return &types.PodUnpauseResponse{}, nil
} | [
"func",
"(",
"s",
"*",
"ServerRPC",
")",
"PodUnpause",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"types",
".",
"PodUnpauseRequest",
")",
"(",
"*",
"types",
".",
"PodUnpauseResponse",
",",
"error",
")",
"{",
"err",
":=",
"s",
".",
"daemon"... | // PodUnpause unpauses a pod | [
"PodUnpause",
"unpauses",
"a",
"pod"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/serverrpc/pod.go#L84-L91 |
149,949 | hyperhq/hyperd | serverrpc/pod.go | SetPodLabels | func (s *ServerRPC) SetPodLabels(c context.Context, req *types.PodLabelsRequest) (*types.PodLabelsResponse, error) {
err := s.daemon.SetPodLabels(req.PodID, req.Override, req.Labels)
if err != nil {
return nil, err
}
return &types.PodLabelsResponse{}, nil
} | go | func (s *ServerRPC) SetPodLabels(c context.Context, req *types.PodLabelsRequest) (*types.PodLabelsResponse, error) {
err := s.daemon.SetPodLabels(req.PodID, req.Override, req.Labels)
if err != nil {
return nil, err
}
return &types.PodLabelsResponse{}, nil
} | [
"func",
"(",
"s",
"*",
"ServerRPC",
")",
"SetPodLabels",
"(",
"c",
"context",
".",
"Context",
",",
"req",
"*",
"types",
".",
"PodLabelsRequest",
")",
"(",
"*",
"types",
".",
"PodLabelsResponse",
",",
"error",
")",
"{",
"err",
":=",
"s",
".",
"daemon",
... | // PodLabels sets the labels of Pod | [
"PodLabels",
"sets",
"the",
"labels",
"of",
"Pod"
] | 8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956 | https://github.com/hyperhq/hyperd/blob/8a7e67dc33bbccdfc92b5e2a908bbdb1c5d9b956/serverrpc/pod.go#L94-L101 |
149,950 | golang/geo | s2/point.go | Distance | func (p Point) Distance(b Point) s1.Angle {
return p.Vector.Angle(b.Vector)
} | go | func (p Point) Distance(b Point) s1.Angle {
return p.Vector.Angle(b.Vector)
} | [
"func",
"(",
"p",
"Point",
")",
"Distance",
"(",
"b",
"Point",
")",
"s1",
".",
"Angle",
"{",
"return",
"p",
".",
"Vector",
".",
"Angle",
"(",
"b",
".",
"Vector",
")",
"\n",
"}"
] | // Distance returns the angle between two points. | [
"Distance",
"returns",
"the",
"angle",
"between",
"two",
"points",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/point.go#L125-L127 |
149,951 | golang/geo | s2/point.go | ApproxEqual | func (p Point) ApproxEqual(other Point) bool {
return p.Vector.Angle(other.Vector) <= s1.Angle(epsilon)
} | go | func (p Point) ApproxEqual(other Point) bool {
return p.Vector.Angle(other.Vector) <= s1.Angle(epsilon)
} | [
"func",
"(",
"p",
"Point",
")",
"ApproxEqual",
"(",
"other",
"Point",
")",
"bool",
"{",
"return",
"p",
".",
"Vector",
".",
"Angle",
"(",
"other",
".",
"Vector",
")",
"<=",
"s1",
".",
"Angle",
"(",
"epsilon",
")",
"\n",
"}"
] | // ApproxEqual reports whether the two points are similar enough to be equal. | [
"ApproxEqual",
"reports",
"whether",
"the",
"two",
"points",
"are",
"similar",
"enough",
"to",
"be",
"equal",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/point.go#L130-L132 |
149,952 | golang/geo | s2/point.go | ChordAngleBetweenPoints | func ChordAngleBetweenPoints(x, y Point) s1.ChordAngle {
return s1.ChordAngle(math.Min(4.0, x.Sub(y.Vector).Norm2()))
} | go | func ChordAngleBetweenPoints(x, y Point) s1.ChordAngle {
return s1.ChordAngle(math.Min(4.0, x.Sub(y.Vector).Norm2()))
} | [
"func",
"ChordAngleBetweenPoints",
"(",
"x",
",",
"y",
"Point",
")",
"s1",
".",
"ChordAngle",
"{",
"return",
"s1",
".",
"ChordAngle",
"(",
"math",
".",
"Min",
"(",
"4.0",
",",
"x",
".",
"Sub",
"(",
"y",
".",
"Vector",
")",
".",
"Norm2",
"(",
")",
... | // ChordAngleBetweenPoints constructs a ChordAngle corresponding to the distance
// between the two given points. The points must be unit length. | [
"ChordAngleBetweenPoints",
"constructs",
"a",
"ChordAngle",
"corresponding",
"to",
"the",
"distance",
"between",
"the",
"two",
"given",
"points",
".",
"The",
"points",
"must",
"be",
"unit",
"length",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/point.go#L136-L138 |
149,953 | golang/geo | s2/point.go | regularPoints | func regularPoints(center Point, radius s1.Angle, numVertices int) []Point {
return regularPointsForFrame(getFrame(center), radius, numVertices)
} | go | func regularPoints(center Point, radius s1.Angle, numVertices int) []Point {
return regularPointsForFrame(getFrame(center), radius, numVertices)
} | [
"func",
"regularPoints",
"(",
"center",
"Point",
",",
"radius",
"s1",
".",
"Angle",
",",
"numVertices",
"int",
")",
"[",
"]",
"Point",
"{",
"return",
"regularPointsForFrame",
"(",
"getFrame",
"(",
"center",
")",
",",
"radius",
",",
"numVertices",
")",
"\n"... | // regularPoints generates a slice of points shaped as a regular polygon with
// the numVertices vertices, all located on a circle of the specified angular radius
// around the center. The radius is the actual distance from center to each vertex. | [
"regularPoints",
"generates",
"a",
"slice",
"of",
"points",
"shaped",
"as",
"a",
"regular",
"polygon",
"with",
"the",
"numVertices",
"vertices",
"all",
"located",
"on",
"a",
"circle",
"of",
"the",
"specified",
"angular",
"radius",
"around",
"the",
"center",
".... | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/point.go#L143-L145 |
149,954 | golang/geo | s2/point.go | regularPointsForFrame | func regularPointsForFrame(frame matrix3x3, radius s1.Angle, numVertices int) []Point {
// We construct the loop in the given frame coordinates, with the center at
// (0, 0, 1). For a loop of radius r, the loop vertices have the form
// (x, y, z) where x^2 + y^2 = sin(r) and z = cos(r). The distance on the
// spher... | go | func regularPointsForFrame(frame matrix3x3, radius s1.Angle, numVertices int) []Point {
// We construct the loop in the given frame coordinates, with the center at
// (0, 0, 1). For a loop of radius r, the loop vertices have the form
// (x, y, z) where x^2 + y^2 = sin(r) and z = cos(r). The distance on the
// spher... | [
"func",
"regularPointsForFrame",
"(",
"frame",
"matrix3x3",
",",
"radius",
"s1",
".",
"Angle",
",",
"numVertices",
"int",
")",
"[",
"]",
"Point",
"{",
"// We construct the loop in the given frame coordinates, with the center at",
"// (0, 0, 1). For a loop of radius r, the loop ... | // regularPointsForFrame generates a slice of points shaped as a regular polygon
// with numVertices vertices, all on a circle of the specified angular radius around
// the center. The radius is the actual distance from the center to each vertex. | [
"regularPointsForFrame",
"generates",
"a",
"slice",
"of",
"points",
"shaped",
"as",
"a",
"regular",
"polygon",
"with",
"numVertices",
"vertices",
"all",
"on",
"a",
"circle",
"of",
"the",
"specified",
"angular",
"radius",
"around",
"the",
"center",
".",
"The",
... | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/point.go#L150-L167 |
149,955 | golang/geo | s2/crossing_edge_query.go | NewCrossingEdgeQuery | func NewCrossingEdgeQuery(index *ShapeIndex) *CrossingEdgeQuery {
c := &CrossingEdgeQuery{
index: index,
iter: index.Iterator(),
}
return c
} | go | func NewCrossingEdgeQuery(index *ShapeIndex) *CrossingEdgeQuery {
c := &CrossingEdgeQuery{
index: index,
iter: index.Iterator(),
}
return c
} | [
"func",
"NewCrossingEdgeQuery",
"(",
"index",
"*",
"ShapeIndex",
")",
"*",
"CrossingEdgeQuery",
"{",
"c",
":=",
"&",
"CrossingEdgeQuery",
"{",
"index",
":",
"index",
",",
"iter",
":",
"index",
".",
"Iterator",
"(",
")",
",",
"}",
"\n",
"return",
"c",
"\n... | // NewCrossingEdgeQuery creates a CrossingEdgeQuery for the given index. | [
"NewCrossingEdgeQuery",
"creates",
"a",
"CrossingEdgeQuery",
"for",
"the",
"given",
"index",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/crossing_edge_query.go#L43-L49 |
149,956 | golang/geo | s2/crossing_edge_query.go | Crossings | func (c *CrossingEdgeQuery) Crossings(a, b Point, shape Shape, crossType CrossingType) []int {
edges := c.candidates(a, b, shape)
if len(edges) == 0 {
return nil
}
crosser := NewEdgeCrosser(a, b)
out := 0
n := len(edges)
for in := 0; in < n; in++ {
b := shape.Edge(edges[in])
sign := crosser.CrossingSign(... | go | func (c *CrossingEdgeQuery) Crossings(a, b Point, shape Shape, crossType CrossingType) []int {
edges := c.candidates(a, b, shape)
if len(edges) == 0 {
return nil
}
crosser := NewEdgeCrosser(a, b)
out := 0
n := len(edges)
for in := 0; in < n; in++ {
b := shape.Edge(edges[in])
sign := crosser.CrossingSign(... | [
"func",
"(",
"c",
"*",
"CrossingEdgeQuery",
")",
"Crossings",
"(",
"a",
",",
"b",
"Point",
",",
"shape",
"Shape",
",",
"crossType",
"CrossingType",
")",
"[",
"]",
"int",
"{",
"edges",
":=",
"c",
".",
"candidates",
"(",
"a",
",",
"b",
",",
"shape",
... | // Crossings returns the set of edge of the shape S that intersect the given edge AB.
// If the CrossingType is Interior, then only intersections at a point interior to both
// edges are reported, while if it is CrossingTypeAll then edges that share a vertex
// are also reported. | [
"Crossings",
"returns",
"the",
"set",
"of",
"edge",
"of",
"the",
"shape",
"S",
"that",
"intersect",
"the",
"given",
"edge",
"AB",
".",
"If",
"the",
"CrossingType",
"is",
"Interior",
"then",
"only",
"intersections",
"at",
"a",
"point",
"interior",
"to",
"bo... | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/crossing_edge_query.go#L55-L78 |
149,957 | golang/geo | s2/crossing_edge_query.go | CrossingsEdgeMap | func (c *CrossingEdgeQuery) CrossingsEdgeMap(a, b Point, crossType CrossingType) EdgeMap {
edgeMap := c.candidatesEdgeMap(a, b)
if len(edgeMap) == 0 {
return nil
}
crosser := NewEdgeCrosser(a, b)
for shape, edges := range edgeMap {
out := 0
n := len(edges)
for in := 0; in < n; in++ {
edge := shape.Edge... | go | func (c *CrossingEdgeQuery) CrossingsEdgeMap(a, b Point, crossType CrossingType) EdgeMap {
edgeMap := c.candidatesEdgeMap(a, b)
if len(edgeMap) == 0 {
return nil
}
crosser := NewEdgeCrosser(a, b)
for shape, edges := range edgeMap {
out := 0
n := len(edges)
for in := 0; in < n; in++ {
edge := shape.Edge... | [
"func",
"(",
"c",
"*",
"CrossingEdgeQuery",
")",
"CrossingsEdgeMap",
"(",
"a",
",",
"b",
"Point",
",",
"crossType",
"CrossingType",
")",
"EdgeMap",
"{",
"edgeMap",
":=",
"c",
".",
"candidatesEdgeMap",
"(",
"a",
",",
"b",
")",
"\n",
"if",
"len",
"(",
"e... | // CrossingsEdgeMap returns the set of all edges in the index that intersect the given
// edge AB. If crossType is CrossingTypeInterior, then only intersections at a
// point interior to both edges are reported, while if it is CrossingTypeAll
// then edges that share a vertex are also reported.
//
// The edges are retu... | [
"CrossingsEdgeMap",
"returns",
"the",
"set",
"of",
"all",
"edges",
"in",
"the",
"index",
"that",
"intersect",
"the",
"given",
"edge",
"AB",
".",
"If",
"crossType",
"is",
"CrossingTypeInterior",
"then",
"only",
"intersections",
"at",
"a",
"point",
"interior",
"... | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/crossing_edge_query.go#L90-L118 |
149,958 | golang/geo | s2/crossing_edge_query.go | candidates | func (c *CrossingEdgeQuery) candidates(a, b Point, shape Shape) []int {
var edges []int
// For small loops it is faster to use brute force. The threshold below was
// determined using benchmarks.
const maxBruteForceEdges = 27
maxEdges := shape.NumEdges()
if maxEdges <= maxBruteForceEdges {
edges = make([]int, ... | go | func (c *CrossingEdgeQuery) candidates(a, b Point, shape Shape) []int {
var edges []int
// For small loops it is faster to use brute force. The threshold below was
// determined using benchmarks.
const maxBruteForceEdges = 27
maxEdges := shape.NumEdges()
if maxEdges <= maxBruteForceEdges {
edges = make([]int, ... | [
"func",
"(",
"c",
"*",
"CrossingEdgeQuery",
")",
"candidates",
"(",
"a",
",",
"b",
"Point",
",",
"shape",
"Shape",
")",
"[",
"]",
"int",
"{",
"var",
"edges",
"[",
"]",
"int",
"\n\n",
"// For small loops it is faster to use brute force. The threshold below was",
... | // candidates returns a superset of the edges of the given shape that intersect
// the edge AB. | [
"candidates",
"returns",
"a",
"superset",
"of",
"the",
"edges",
"of",
"the",
"given",
"shape",
"that",
"intersect",
"the",
"edge",
"AB",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/crossing_edge_query.go#L122-L170 |
149,959 | golang/geo | s2/crossing_edge_query.go | uniqueInts | func uniqueInts(in []int) []int {
var edges []int
m := make(map[int]bool)
for _, i := range in {
if m[i] {
continue
}
m[i] = true
edges = append(edges, i)
}
sort.Ints(edges)
return edges
} | go | func uniqueInts(in []int) []int {
var edges []int
m := make(map[int]bool)
for _, i := range in {
if m[i] {
continue
}
m[i] = true
edges = append(edges, i)
}
sort.Ints(edges)
return edges
} | [
"func",
"uniqueInts",
"(",
"in",
"[",
"]",
"int",
")",
"[",
"]",
"int",
"{",
"var",
"edges",
"[",
"]",
"int",
"\n",
"m",
":=",
"make",
"(",
"map",
"[",
"int",
"]",
"bool",
")",
"\n",
"for",
"_",
",",
"i",
":=",
"range",
"in",
"{",
"if",
"m"... | // uniqueInts returns the sorted uniqued values from the given input. | [
"uniqueInts",
"returns",
"the",
"sorted",
"uniqued",
"values",
"from",
"the",
"given",
"input",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/crossing_edge_query.go#L173-L185 |
149,960 | golang/geo | s2/crossing_edge_query.go | getCells | func (c *CrossingEdgeQuery) getCells(a, b Point, root *PaddedCell) []*ShapeIndexCell {
aUV, bUV, ok := ClipToFace(a, b, root.id.Face())
if ok {
c.a = aUV
c.b = bUV
edgeBound := r2.RectFromPoints(c.a, c.b)
if root.Bound().Intersects(edgeBound) {
c.computeCellsIntersected(root, edgeBound)
}
}
if len(c.c... | go | func (c *CrossingEdgeQuery) getCells(a, b Point, root *PaddedCell) []*ShapeIndexCell {
aUV, bUV, ok := ClipToFace(a, b, root.id.Face())
if ok {
c.a = aUV
c.b = bUV
edgeBound := r2.RectFromPoints(c.a, c.b)
if root.Bound().Intersects(edgeBound) {
c.computeCellsIntersected(root, edgeBound)
}
}
if len(c.c... | [
"func",
"(",
"c",
"*",
"CrossingEdgeQuery",
")",
"getCells",
"(",
"a",
",",
"b",
"Point",
",",
"root",
"*",
"PaddedCell",
")",
"[",
"]",
"*",
"ShapeIndexCell",
"{",
"aUV",
",",
"bUV",
",",
"ok",
":=",
"ClipToFace",
"(",
"a",
",",
"b",
",",
"root",
... | // getCells returns the set of ShapeIndexCells that might contain edges intersecting
// the edge AB in the given cell root. This method is used primarly by loop and shapeutil. | [
"getCells",
"returns",
"the",
"set",
"of",
"ShapeIndexCells",
"that",
"might",
"contain",
"edges",
"intersecting",
"the",
"edge",
"AB",
"in",
"the",
"given",
"cell",
"root",
".",
"This",
"method",
"is",
"used",
"primarly",
"by",
"loop",
"and",
"shapeutil",
"... | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/crossing_edge_query.go#L236-L252 |
149,961 | golang/geo | s2/crossing_edge_query.go | getCellsForEdge | func (c *CrossingEdgeQuery) getCellsForEdge(a, b Point) {
c.cells = nil
segments := FaceSegments(a, b)
for _, segment := range segments {
c.a = segment.a
c.b = segment.b
// Optimization: rather than always starting the recursive subdivision at
// the top level face cell, instead we start at the smallest S2... | go | func (c *CrossingEdgeQuery) getCellsForEdge(a, b Point) {
c.cells = nil
segments := FaceSegments(a, b)
for _, segment := range segments {
c.a = segment.a
c.b = segment.b
// Optimization: rather than always starting the recursive subdivision at
// the top level face cell, instead we start at the smallest S2... | [
"func",
"(",
"c",
"*",
"CrossingEdgeQuery",
")",
"getCellsForEdge",
"(",
"a",
",",
"b",
"Point",
")",
"{",
"c",
".",
"cells",
"=",
"nil",
"\n\n",
"segments",
":=",
"FaceSegments",
"(",
"a",
",",
"b",
")",
"\n",
"for",
"_",
",",
"segment",
":=",
"ra... | // getCellsForEdge populates the cells field to the set of index cells intersected by an edge AB. | [
"getCellsForEdge",
"populates",
"the",
"cells",
"field",
"to",
"the",
"set",
"of",
"index",
"cells",
"intersected",
"by",
"an",
"edge",
"AB",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/crossing_edge_query.go#L255-L293 |
149,962 | golang/geo | s2/crossing_edge_query.go | computeCellsIntersected | func (c *CrossingEdgeQuery) computeCellsIntersected(pcell *PaddedCell, edgeBound r2.Rect) {
c.iter.seek(pcell.id.RangeMin())
if c.iter.Done() || c.iter.CellID() > pcell.id.RangeMax() {
// The index does not contain pcell or any of its descendants.
return
}
if c.iter.CellID() == pcell.id {
// The index contai... | go | func (c *CrossingEdgeQuery) computeCellsIntersected(pcell *PaddedCell, edgeBound r2.Rect) {
c.iter.seek(pcell.id.RangeMin())
if c.iter.Done() || c.iter.CellID() > pcell.id.RangeMax() {
// The index does not contain pcell or any of its descendants.
return
}
if c.iter.CellID() == pcell.id {
// The index contai... | [
"func",
"(",
"c",
"*",
"CrossingEdgeQuery",
")",
"computeCellsIntersected",
"(",
"pcell",
"*",
"PaddedCell",
",",
"edgeBound",
"r2",
".",
"Rect",
")",
"{",
"c",
".",
"iter",
".",
"seek",
"(",
"pcell",
".",
"id",
".",
"RangeMin",
"(",
")",
")",
"\n",
... | // computeCellsIntersected computes the index cells intersected by the current
// edge that are descendants of pcell and adds them to this queries set of cells. | [
"computeCellsIntersected",
"computes",
"the",
"index",
"cells",
"intersected",
"by",
"the",
"current",
"edge",
"that",
"are",
"descendants",
"of",
"pcell",
"and",
"adds",
"them",
"to",
"this",
"queries",
"set",
"of",
"cells",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/crossing_edge_query.go#L297-L338 |
149,963 | golang/geo | s2/crossing_edge_query.go | splitUBound | func (c *CrossingEdgeQuery) splitUBound(edgeBound r2.Rect, u float64) [2]r2.Rect {
v := edgeBound.Y.ClampPoint(interpolateFloat64(u, c.a.X, c.b.X, c.a.Y, c.b.Y))
// diag indicates which diagonal of the bounding box is spanned by AB:
// it is 0 if AB has positive slope, and 1 if AB has negative slope.
var diag int
... | go | func (c *CrossingEdgeQuery) splitUBound(edgeBound r2.Rect, u float64) [2]r2.Rect {
v := edgeBound.Y.ClampPoint(interpolateFloat64(u, c.a.X, c.b.X, c.a.Y, c.b.Y))
// diag indicates which diagonal of the bounding box is spanned by AB:
// it is 0 if AB has positive slope, and 1 if AB has negative slope.
var diag int
... | [
"func",
"(",
"c",
"*",
"CrossingEdgeQuery",
")",
"splitUBound",
"(",
"edgeBound",
"r2",
".",
"Rect",
",",
"u",
"float64",
")",
"[",
"2",
"]",
"r2",
".",
"Rect",
"{",
"v",
":=",
"edgeBound",
".",
"Y",
".",
"ClampPoint",
"(",
"interpolateFloat64",
"(",
... | // splitUBound returns the bound for two children as a result of spliting the
// current edge at the given value U. | [
"splitUBound",
"returns",
"the",
"bound",
"for",
"two",
"children",
"as",
"a",
"result",
"of",
"spliting",
"the",
"current",
"edge",
"at",
"the",
"given",
"value",
"U",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/crossing_edge_query.go#L362-L371 |
149,964 | golang/geo | s2/polyline_measures.go | polylineLength | func polylineLength(p []Point) s1.Angle {
var length s1.Angle
for i := 1; i < len(p); i++ {
length += p[i-1].Distance(p[i])
}
return length
} | go | func polylineLength(p []Point) s1.Angle {
var length s1.Angle
for i := 1; i < len(p); i++ {
length += p[i-1].Distance(p[i])
}
return length
} | [
"func",
"polylineLength",
"(",
"p",
"[",
"]",
"Point",
")",
"s1",
".",
"Angle",
"{",
"var",
"length",
"s1",
".",
"Angle",
"\n\n",
"for",
"i",
":=",
"1",
";",
"i",
"<",
"len",
"(",
"p",
")",
";",
"i",
"++",
"{",
"length",
"+=",
"p",
"[",
"i",
... | // polylineLength returns the length of the given Polyline.
// It returns 0 for polylines with fewer than two vertices. | [
"polylineLength",
"returns",
"the",
"length",
"of",
"the",
"given",
"Polyline",
".",
"It",
"returns",
"0",
"for",
"polylines",
"with",
"fewer",
"than",
"two",
"vertices",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polyline_measures.go#L28-L35 |
149,965 | golang/geo | s2/latlng.go | LatLngFromDegrees | func LatLngFromDegrees(lat, lng float64) LatLng {
return LatLng{s1.Angle(lat) * s1.Degree, s1.Angle(lng) * s1.Degree}
} | go | func LatLngFromDegrees(lat, lng float64) LatLng {
return LatLng{s1.Angle(lat) * s1.Degree, s1.Angle(lng) * s1.Degree}
} | [
"func",
"LatLngFromDegrees",
"(",
"lat",
",",
"lng",
"float64",
")",
"LatLng",
"{",
"return",
"LatLng",
"{",
"s1",
".",
"Angle",
"(",
"lat",
")",
"*",
"s1",
".",
"Degree",
",",
"s1",
".",
"Angle",
"(",
"lng",
")",
"*",
"s1",
".",
"Degree",
"}",
"... | // LatLngFromDegrees returns a LatLng for the coordinates given in degrees. | [
"LatLngFromDegrees",
"returns",
"a",
"LatLng",
"for",
"the",
"coordinates",
"given",
"in",
"degrees",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/latlng.go#L36-L38 |
149,966 | golang/geo | s2/latlng.go | Distance | func (ll LatLng) Distance(ll2 LatLng) s1.Angle {
// Haversine formula, as used in C++ S2LatLng::GetDistance.
lat1, lat2 := ll.Lat.Radians(), ll2.Lat.Radians()
lng1, lng2 := ll.Lng.Radians(), ll2.Lng.Radians()
dlat := math.Sin(0.5 * (lat2 - lat1))
dlng := math.Sin(0.5 * (lng2 - lng1))
x := dlat*dlat + dlng*dlng*ma... | go | func (ll LatLng) Distance(ll2 LatLng) s1.Angle {
// Haversine formula, as used in C++ S2LatLng::GetDistance.
lat1, lat2 := ll.Lat.Radians(), ll2.Lat.Radians()
lng1, lng2 := ll.Lng.Radians(), ll2.Lng.Radians()
dlat := math.Sin(0.5 * (lat2 - lat1))
dlng := math.Sin(0.5 * (lng2 - lng1))
x := dlat*dlat + dlng*dlng*ma... | [
"func",
"(",
"ll",
"LatLng",
")",
"Distance",
"(",
"ll2",
"LatLng",
")",
"s1",
".",
"Angle",
"{",
"// Haversine formula, as used in C++ S2LatLng::GetDistance.",
"lat1",
",",
"lat2",
":=",
"ll",
".",
"Lat",
".",
"Radians",
"(",
")",
",",
"ll2",
".",
"Lat",
... | // Distance returns the angle between two LatLngs. | [
"Distance",
"returns",
"the",
"angle",
"between",
"two",
"LatLngs",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/latlng.go#L61-L69 |
149,967 | golang/geo | r3/vector.go | IsUnit | func (v Vector) IsUnit() bool {
const epsilon = 5e-14
return math.Abs(v.Norm2()-1) <= epsilon
} | go | func (v Vector) IsUnit() bool {
const epsilon = 5e-14
return math.Abs(v.Norm2()-1) <= epsilon
} | [
"func",
"(",
"v",
"Vector",
")",
"IsUnit",
"(",
")",
"bool",
"{",
"const",
"epsilon",
"=",
"5e-14",
"\n",
"return",
"math",
".",
"Abs",
"(",
"v",
".",
"Norm2",
"(",
")",
"-",
"1",
")",
"<=",
"epsilon",
"\n",
"}"
] | // IsUnit returns whether this vector is of approximately unit length. | [
"IsUnit",
"returns",
"whether",
"this",
"vector",
"is",
"of",
"approximately",
"unit",
"length",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r3/vector.go#L53-L56 |
149,968 | golang/geo | r3/vector.go | Angle | func (v Vector) Angle(ov Vector) s1.Angle {
return s1.Angle(math.Atan2(v.Cross(ov).Norm(), v.Dot(ov))) * s1.Radian
} | go | func (v Vector) Angle(ov Vector) s1.Angle {
return s1.Angle(math.Atan2(v.Cross(ov).Norm(), v.Dot(ov))) * s1.Radian
} | [
"func",
"(",
"v",
"Vector",
")",
"Angle",
"(",
"ov",
"Vector",
")",
"s1",
".",
"Angle",
"{",
"return",
"s1",
".",
"Angle",
"(",
"math",
".",
"Atan2",
"(",
"v",
".",
"Cross",
"(",
"ov",
")",
".",
"Norm",
"(",
")",
",",
"v",
".",
"Dot",
"(",
... | // Angle returns the angle between v and ov. | [
"Angle",
"returns",
"the",
"angle",
"between",
"v",
"and",
"ov",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r3/vector.go#L86-L88 |
149,969 | golang/geo | s2/polygon.go | compareLoops | func compareLoops(a, b *Loop) int {
if na, nb := a.NumVertices(), b.NumVertices(); na != nb {
return na - nb
}
ai, aDir := a.CanonicalFirstVertex()
bi, bDir := b.CanonicalFirstVertex()
if aDir != bDir {
return aDir - bDir
}
for n := a.NumVertices() - 1; n >= 0; n, ai, bi = n-1, ai+aDir, bi+bDir {
if cmp :=... | go | func compareLoops(a, b *Loop) int {
if na, nb := a.NumVertices(), b.NumVertices(); na != nb {
return na - nb
}
ai, aDir := a.CanonicalFirstVertex()
bi, bDir := b.CanonicalFirstVertex()
if aDir != bDir {
return aDir - bDir
}
for n := a.NumVertices() - 1; n >= 0; n, ai, bi = n-1, ai+aDir, bi+bDir {
if cmp :=... | [
"func",
"compareLoops",
"(",
"a",
",",
"b",
"*",
"Loop",
")",
"int",
"{",
"if",
"na",
",",
"nb",
":=",
"a",
".",
"NumVertices",
"(",
")",
",",
"b",
".",
"NumVertices",
"(",
")",
";",
"na",
"!=",
"nb",
"{",
"return",
"na",
"-",
"nb",
"\n",
"}"... | // Defines a total ordering on Loops that does not depend on the cyclic
// order of loop vertices. This function is used to choose which loop to
// invert in the case where several loops have exactly the same area. | [
"Defines",
"a",
"total",
"ordering",
"on",
"Loops",
"that",
"does",
"not",
"depend",
"on",
"the",
"cyclic",
"order",
"of",
"loop",
"vertices",
".",
"This",
"function",
"is",
"used",
"to",
"choose",
"which",
"loop",
"to",
"invert",
"in",
"the",
"case",
"w... | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polygon.go#L254-L269 |
149,970 | golang/geo | s2/polygon.go | insertLoop | func (lm loopMap) insertLoop(newLoop, parent *Loop) {
var children []*Loop
for done := false; !done; {
children = lm[parent]
done = true
for _, child := range children {
if child.ContainsNested(newLoop) {
parent = child
done = false
break
}
}
}
// Now, we have found a parent for this loop... | go | func (lm loopMap) insertLoop(newLoop, parent *Loop) {
var children []*Loop
for done := false; !done; {
children = lm[parent]
done = true
for _, child := range children {
if child.ContainsNested(newLoop) {
parent = child
done = false
break
}
}
}
// Now, we have found a parent for this loop... | [
"func",
"(",
"lm",
"loopMap",
")",
"insertLoop",
"(",
"newLoop",
",",
"parent",
"*",
"Loop",
")",
"{",
"var",
"children",
"[",
"]",
"*",
"Loop",
"\n",
"for",
"done",
":=",
"false",
";",
"!",
"done",
";",
"{",
"children",
"=",
"lm",
"[",
"parent",
... | // insertLoop adds the given loop to the loop map under the specified parent.
// All children of the new entry are checked to see if the need to move up to
// a different level. | [
"insertLoop",
"adds",
"the",
"given",
"loop",
"to",
"the",
"loop",
"map",
"under",
"the",
"specified",
"parent",
".",
"All",
"children",
"of",
"the",
"new",
"entry",
"are",
"checked",
"to",
"see",
"if",
"the",
"need",
"to",
"move",
"up",
"to",
"a",
"di... | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polygon.go#L305-L334 |
149,971 | golang/geo | s2/polygon.go | initLoops | func (p *Polygon) initLoops(lm loopMap) {
var stack loopStack
stack.push(nil)
depth := -1
for len(stack) > 0 {
loop := stack.pop()
if loop != nil {
depth = loop.depth
p.loops = append(p.loops, loop)
}
children := lm[loop]
for i := len(children) - 1; i >= 0; i-- {
child := children[i]
child.de... | go | func (p *Polygon) initLoops(lm loopMap) {
var stack loopStack
stack.push(nil)
depth := -1
for len(stack) > 0 {
loop := stack.pop()
if loop != nil {
depth = loop.depth
p.loops = append(p.loops, loop)
}
children := lm[loop]
for i := len(children) - 1; i >= 0; i-- {
child := children[i]
child.de... | [
"func",
"(",
"p",
"*",
"Polygon",
")",
"initLoops",
"(",
"lm",
"loopMap",
")",
"{",
"var",
"stack",
"loopStack",
"\n",
"stack",
".",
"push",
"(",
"nil",
")",
"\n",
"depth",
":=",
"-",
"1",
"\n\n",
"for",
"len",
"(",
"stack",
")",
">",
"0",
"{",
... | // initLoops walks the mapping of loops to all of their children, and adds them in
// order into to the polygons set of loops. | [
"initLoops",
"walks",
"the",
"mapping",
"of",
"loops",
"to",
"all",
"of",
"their",
"children",
"and",
"adds",
"them",
"in",
"order",
"into",
"to",
"the",
"polygons",
"set",
"of",
"loops",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polygon.go#L351-L369 |
149,972 | golang/geo | s2/polygon.go | initLoopProperties | func (p *Polygon) initLoopProperties() {
// the loops depths are set by initNested/initOriented prior to this.
p.hasHoles = false
for _, l := range p.loops {
if l.IsHole() {
p.hasHoles = true
} else {
p.bound = p.bound.Union(l.RectBound())
}
p.numVertices += l.NumVertices()
}
p.subregionBound = Expa... | go | func (p *Polygon) initLoopProperties() {
// the loops depths are set by initNested/initOriented prior to this.
p.hasHoles = false
for _, l := range p.loops {
if l.IsHole() {
p.hasHoles = true
} else {
p.bound = p.bound.Union(l.RectBound())
}
p.numVertices += l.NumVertices()
}
p.subregionBound = Expa... | [
"func",
"(",
"p",
"*",
"Polygon",
")",
"initLoopProperties",
"(",
")",
"{",
"// the loops depths are set by initNested/initOriented prior to this.",
"p",
".",
"hasHoles",
"=",
"false",
"\n",
"for",
"_",
",",
"l",
":=",
"range",
"p",
".",
"loops",
"{",
"if",
"l... | // initLoopProperties sets the properties for polygons with multiple loops. | [
"initLoopProperties",
"sets",
"the",
"properties",
"for",
"polygons",
"with",
"multiple",
"loops",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polygon.go#L385-L400 |
149,973 | golang/geo | s2/polygon.go | initEdgesAndIndex | func (p *Polygon) initEdgesAndIndex() {
if p.IsFull() {
return
}
const maxLinearSearchLoops = 12 // Based on benchmarks.
if len(p.loops) > maxLinearSearchLoops {
p.cumulativeEdges = make([]int, 0, len(p.loops))
}
for _, l := range p.loops {
if p.cumulativeEdges != nil {
p.cumulativeEdges = append(p.cumu... | go | func (p *Polygon) initEdgesAndIndex() {
if p.IsFull() {
return
}
const maxLinearSearchLoops = 12 // Based on benchmarks.
if len(p.loops) > maxLinearSearchLoops {
p.cumulativeEdges = make([]int, 0, len(p.loops))
}
for _, l := range p.loops {
if p.cumulativeEdges != nil {
p.cumulativeEdges = append(p.cumu... | [
"func",
"(",
"p",
"*",
"Polygon",
")",
"initEdgesAndIndex",
"(",
")",
"{",
"if",
"p",
".",
"IsFull",
"(",
")",
"{",
"return",
"\n",
"}",
"\n",
"const",
"maxLinearSearchLoops",
"=",
"12",
"// Based on benchmarks.",
"\n",
"if",
"len",
"(",
"p",
".",
"loo... | // initEdgesAndIndex performs the shape related initializations and adds the final
// polygon to the index. | [
"initEdgesAndIndex",
"performs",
"the",
"shape",
"related",
"initializations",
"and",
"adds",
"the",
"final",
"polygon",
"to",
"the",
"index",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polygon.go#L404-L422 |
149,974 | golang/geo | s2/polygon.go | FullPolygon | func FullPolygon() *Polygon {
ret := &Polygon{
loops: []*Loop{
FullLoop(),
},
numVertices: len(FullLoop().Vertices()),
bound: FullRect(),
subregionBound: FullRect(),
}
ret.initEdgesAndIndex()
return ret
} | go | func FullPolygon() *Polygon {
ret := &Polygon{
loops: []*Loop{
FullLoop(),
},
numVertices: len(FullLoop().Vertices()),
bound: FullRect(),
subregionBound: FullRect(),
}
ret.initEdgesAndIndex()
return ret
} | [
"func",
"FullPolygon",
"(",
")",
"*",
"Polygon",
"{",
"ret",
":=",
"&",
"Polygon",
"{",
"loops",
":",
"[",
"]",
"*",
"Loop",
"{",
"FullLoop",
"(",
")",
",",
"}",
",",
"numVertices",
":",
"len",
"(",
"FullLoop",
"(",
")",
".",
"Vertices",
"(",
")"... | // FullPolygon returns a special "full" polygon. | [
"FullPolygon",
"returns",
"a",
"special",
"full",
"polygon",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polygon.go#L425-L436 |
149,975 | golang/geo | s2/polygon.go | Validate | func (p *Polygon) Validate() error {
for i, l := range p.loops {
// Check for loop errors that don't require building a ShapeIndex.
if err := l.findValidationErrorNoIndex(); err != nil {
return fmt.Errorf("loop %d: %v", i, err)
}
// Check that no loop is empty, and that the full loop only appears in the
/... | go | func (p *Polygon) Validate() error {
for i, l := range p.loops {
// Check for loop errors that don't require building a ShapeIndex.
if err := l.findValidationErrorNoIndex(); err != nil {
return fmt.Errorf("loop %d: %v", i, err)
}
// Check that no loop is empty, and that the full loop only appears in the
/... | [
"func",
"(",
"p",
"*",
"Polygon",
")",
"Validate",
"(",
")",
"error",
"{",
"for",
"i",
",",
"l",
":=",
"range",
"p",
".",
"loops",
"{",
"// Check for loop errors that don't require building a ShapeIndex.",
"if",
"err",
":=",
"l",
".",
"findValidationErrorNoIndex... | // Validate checks whether this is a valid polygon,
// including checking whether all the loops are themselves valid. | [
"Validate",
"checks",
"whether",
"this",
"is",
"a",
"valid",
"polygon",
"including",
"checking",
"whether",
"all",
"the",
"loops",
"are",
"themselves",
"valid",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polygon.go#L440-L471 |
149,976 | golang/geo | s2/polygon.go | findLoopNestingError | func (p *Polygon) findLoopNestingError() error {
// First check that the loop depths make sense.
lastDepth := -1
for i, l := range p.loops {
depth := l.depth
if depth < 0 || depth > lastDepth+1 {
return fmt.Errorf("loop %d: invalid loop depth (%d)", i, depth)
}
lastDepth = depth
}
// Then check that the... | go | func (p *Polygon) findLoopNestingError() error {
// First check that the loop depths make sense.
lastDepth := -1
for i, l := range p.loops {
depth := l.depth
if depth < 0 || depth > lastDepth+1 {
return fmt.Errorf("loop %d: invalid loop depth (%d)", i, depth)
}
lastDepth = depth
}
// Then check that the... | [
"func",
"(",
"p",
"*",
"Polygon",
")",
"findLoopNestingError",
"(",
")",
"error",
"{",
"// First check that the loop depths make sense.",
"lastDepth",
":=",
"-",
"1",
"\n",
"for",
"i",
",",
"l",
":=",
"range",
"p",
".",
"loops",
"{",
"depth",
":=",
"l",
".... | // findLoopNestingError reports if there is an error in the loop nesting hierarchy. | [
"findLoopNestingError",
"reports",
"if",
"there",
"is",
"an",
"error",
"in",
"the",
"loop",
"nesting",
"hierarchy",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polygon.go#L474-L505 |
149,977 | golang/geo | s2/polygon.go | Parent | func (p *Polygon) Parent(k int) (index int, ok bool) {
// See where we are on the depth hierarchy.
depth := p.loops[k].depth
if depth == 0 {
return -1, false
}
// There may be several loops at the same nesting level as us that share a
// parent loop with us. (Imagine a slice of swiss cheese, of which we are on... | go | func (p *Polygon) Parent(k int) (index int, ok bool) {
// See where we are on the depth hierarchy.
depth := p.loops[k].depth
if depth == 0 {
return -1, false
}
// There may be several loops at the same nesting level as us that share a
// parent loop with us. (Imagine a slice of swiss cheese, of which we are on... | [
"func",
"(",
"p",
"*",
"Polygon",
")",
"Parent",
"(",
"k",
"int",
")",
"(",
"index",
"int",
",",
"ok",
"bool",
")",
"{",
"// See where we are on the depth hierarchy.",
"depth",
":=",
"p",
".",
"loops",
"[",
"k",
"]",
".",
"depth",
"\n",
"if",
"depth",
... | // Parent returns the index of the parent of loop k.
// If the loop does not have a parent, ok=false is returned. | [
"Parent",
"returns",
"the",
"index",
"of",
"the",
"parent",
"of",
"loop",
"k",
".",
"If",
"the",
"loop",
"does",
"not",
"have",
"a",
"parent",
"ok",
"=",
"false",
"is",
"returned",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polygon.go#L539-L554 |
149,978 | golang/geo | s2/polygon.go | ContainsPoint | func (p *Polygon) ContainsPoint(point Point) bool {
// NOTE: A bounds check slows down this function by about 50%. It is
// worthwhile only when it might allow us to delay building the index.
if !p.index.IsFresh() && !p.bound.ContainsPoint(point) {
return false
}
// For small polygons, and during initial constr... | go | func (p *Polygon) ContainsPoint(point Point) bool {
// NOTE: A bounds check slows down this function by about 50%. It is
// worthwhile only when it might allow us to delay building the index.
if !p.index.IsFresh() && !p.bound.ContainsPoint(point) {
return false
}
// For small polygons, and during initial constr... | [
"func",
"(",
"p",
"*",
"Polygon",
")",
"ContainsPoint",
"(",
"point",
"Point",
")",
"bool",
"{",
"// NOTE: A bounds check slows down this function by about 50%. It is",
"// worthwhile only when it might allow us to delay building the index.",
"if",
"!",
"p",
".",
"index",
"."... | // ContainsPoint reports whether the polygon contains the point. | [
"ContainsPoint",
"reports",
"whether",
"the",
"polygon",
"contains",
"the",
"point",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polygon.go#L584-L610 |
149,979 | golang/geo | s2/polygon.go | ContainsCell | func (p *Polygon) ContainsCell(cell Cell) bool {
it := p.index.Iterator()
relation := it.LocateCellID(cell.ID())
// If "cell" is disjoint from all index cells, it is not contained.
// Similarly, if "cell" is subdivided into one or more index cells then it
// is not contained, since index cells are subdivided only... | go | func (p *Polygon) ContainsCell(cell Cell) bool {
it := p.index.Iterator()
relation := it.LocateCellID(cell.ID())
// If "cell" is disjoint from all index cells, it is not contained.
// Similarly, if "cell" is subdivided into one or more index cells then it
// is not contained, since index cells are subdivided only... | [
"func",
"(",
"p",
"*",
"Polygon",
")",
"ContainsCell",
"(",
"cell",
"Cell",
")",
"bool",
"{",
"it",
":=",
"p",
".",
"index",
".",
"Iterator",
"(",
")",
"\n",
"relation",
":=",
"it",
".",
"LocateCellID",
"(",
"cell",
".",
"ID",
"(",
")",
")",
"\n\... | // ContainsCell reports whether the polygon contains the given cell. | [
"ContainsCell",
"reports",
"whether",
"the",
"polygon",
"contains",
"the",
"given",
"cell",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polygon.go#L613-L634 |
149,980 | golang/geo | s2/polygon.go | IntersectsCell | func (p *Polygon) IntersectsCell(cell Cell) bool {
it := p.index.Iterator()
relation := it.LocateCellID(cell.ID())
// If cell does not overlap any index cell, there is no intersection.
if relation == Disjoint {
return false
}
// If cell is subdivided into one or more index cells, there is an
// intersection t... | go | func (p *Polygon) IntersectsCell(cell Cell) bool {
it := p.index.Iterator()
relation := it.LocateCellID(cell.ID())
// If cell does not overlap any index cell, there is no intersection.
if relation == Disjoint {
return false
}
// If cell is subdivided into one or more index cells, there is an
// intersection t... | [
"func",
"(",
"p",
"*",
"Polygon",
")",
"IntersectsCell",
"(",
"cell",
"Cell",
")",
"bool",
"{",
"it",
":=",
"p",
".",
"index",
".",
"Iterator",
"(",
")",
"\n",
"relation",
":=",
"it",
".",
"LocateCellID",
"(",
"cell",
".",
"ID",
"(",
")",
")",
"\... | // IntersectsCell reports whether the polygon intersects the given cell. | [
"IntersectsCell",
"reports",
"whether",
"the",
"polygon",
"intersects",
"the",
"given",
"cell",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polygon.go#L637-L662 |
149,981 | golang/geo | s2/polygon.go | iteratorContainsPoint | func (p *Polygon) iteratorContainsPoint(it *ShapeIndexIterator, point Point) bool {
// Test containment by drawing a line segment from the cell center to the
// given point and counting edge crossings.
aClipped := it.IndexCell().findByShapeID(0)
inside := aClipped.containsCenter
if len(aClipped.edges) == 0 {
re... | go | func (p *Polygon) iteratorContainsPoint(it *ShapeIndexIterator, point Point) bool {
// Test containment by drawing a line segment from the cell center to the
// given point and counting edge crossings.
aClipped := it.IndexCell().findByShapeID(0)
inside := aClipped.containsCenter
if len(aClipped.edges) == 0 {
re... | [
"func",
"(",
"p",
"*",
"Polygon",
")",
"iteratorContainsPoint",
"(",
"it",
"*",
"ShapeIndexIterator",
",",
"point",
"Point",
")",
"bool",
"{",
"// Test containment by drawing a line segment from the cell center to the",
"// given point and counting edge crossings.",
"aClipped",... | // iteratorContainsPoint reports whether the iterator that is positioned at the
// ShapeIndexCell that may contain p, contains the point p. | [
"iteratorContainsPoint",
"reports",
"whether",
"the",
"iterator",
"that",
"is",
"positioned",
"at",
"the",
"ShapeIndexCell",
"that",
"may",
"contain",
"p",
"contains",
"the",
"point",
"p",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polygon.go#L704-L723 |
149,982 | golang/geo | s2/polygon.go | ReferencePoint | func (p *Polygon) ReferencePoint() ReferencePoint {
containsOrigin := false
for _, l := range p.loops {
containsOrigin = containsOrigin != l.ContainsOrigin()
}
return OriginReferencePoint(containsOrigin)
} | go | func (p *Polygon) ReferencePoint() ReferencePoint {
containsOrigin := false
for _, l := range p.loops {
containsOrigin = containsOrigin != l.ContainsOrigin()
}
return OriginReferencePoint(containsOrigin)
} | [
"func",
"(",
"p",
"*",
"Polygon",
")",
"ReferencePoint",
"(",
")",
"ReferencePoint",
"{",
"containsOrigin",
":=",
"false",
"\n",
"for",
"_",
",",
"l",
":=",
"range",
"p",
".",
"loops",
"{",
"containsOrigin",
"=",
"containsOrigin",
"!=",
"l",
".",
"Contai... | // ReferencePoint returns the reference point for this polygon. | [
"ReferencePoint",
"returns",
"the",
"reference",
"point",
"for",
"this",
"polygon",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polygon.go#L755-L761 |
149,983 | golang/geo | s2/polygon.go | Contains | func (p *Polygon) Contains(o *Polygon) bool {
// If both polygons have one loop, use the more efficient Loop method.
// Note that Loop's Contains does its own bounding rectangle check.
if len(p.loops) == 1 && len(o.loops) == 1 {
return p.loops[0].Contains(o.loops[0])
}
// Otherwise if neither polygon has holes,... | go | func (p *Polygon) Contains(o *Polygon) bool {
// If both polygons have one loop, use the more efficient Loop method.
// Note that Loop's Contains does its own bounding rectangle check.
if len(p.loops) == 1 && len(o.loops) == 1 {
return p.loops[0].Contains(o.loops[0])
}
// Otherwise if neither polygon has holes,... | [
"func",
"(",
"p",
"*",
"Polygon",
")",
"Contains",
"(",
"o",
"*",
"Polygon",
")",
"bool",
"{",
"// If both polygons have one loop, use the more efficient Loop method.",
"// Note that Loop's Contains does its own bounding rectangle check.",
"if",
"len",
"(",
"p",
".",
"loops... | // Contains reports whether this polygon contains the other polygon.
// Specifically, it reports whether all the points in the other polygon
// are also in this polygon. | [
"Contains",
"reports",
"whether",
"this",
"polygon",
"contains",
"the",
"other",
"polygon",
".",
"Specifically",
"it",
"reports",
"whether",
"all",
"the",
"points",
"in",
"the",
"other",
"polygon",
"are",
"also",
"in",
"this",
"polygon",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polygon.go#L822-L861 |
149,984 | golang/geo | s2/polygon.go | Intersects | func (p *Polygon) Intersects(o *Polygon) bool {
// If both polygons have one loop, use the more efficient Loop method.
// Note that Loop Intersects does its own bounding rectangle check.
if len(p.loops) == 1 && len(o.loops) == 1 {
return p.loops[0].Intersects(o.loops[0])
}
// Otherwise if neither polygon has ho... | go | func (p *Polygon) Intersects(o *Polygon) bool {
// If both polygons have one loop, use the more efficient Loop method.
// Note that Loop Intersects does its own bounding rectangle check.
if len(p.loops) == 1 && len(o.loops) == 1 {
return p.loops[0].Intersects(o.loops[0])
}
// Otherwise if neither polygon has ho... | [
"func",
"(",
"p",
"*",
"Polygon",
")",
"Intersects",
"(",
"o",
"*",
"Polygon",
")",
"bool",
"{",
"// If both polygons have one loop, use the more efficient Loop method.",
"// Note that Loop Intersects does its own bounding rectangle check.",
"if",
"len",
"(",
"p",
".",
"loo... | // Intersects reports whether this polygon intersects the other polygon, i.e.
// if there is a point that is contained by both polygons. | [
"Intersects",
"reports",
"whether",
"this",
"polygon",
"intersects",
"the",
"other",
"polygon",
"i",
".",
"e",
".",
"if",
"there",
"is",
"a",
"point",
"that",
"is",
"contained",
"by",
"both",
"polygons",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polygon.go#L865-L894 |
149,985 | golang/geo | s2/polygon.go | compareBoundary | func (p *Polygon) compareBoundary(o *Loop) int {
result := -1
for i := 0; i < len(p.loops) && result != 0; i++ {
// If B crosses any loop of A, the result is 0. Otherwise the result
// changes sign each time B is contained by a loop of A.
result *= -p.loops[i].compareBoundary(o)
}
return result
} | go | func (p *Polygon) compareBoundary(o *Loop) int {
result := -1
for i := 0; i < len(p.loops) && result != 0; i++ {
// If B crosses any loop of A, the result is 0. Otherwise the result
// changes sign each time B is contained by a loop of A.
result *= -p.loops[i].compareBoundary(o)
}
return result
} | [
"func",
"(",
"p",
"*",
"Polygon",
")",
"compareBoundary",
"(",
"o",
"*",
"Loop",
")",
"int",
"{",
"result",
":=",
"-",
"1",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"p",
".",
"loops",
")",
"&&",
"result",
"!=",
"0",
";",
"i",
... | // compareBoundary returns +1 if this polygon contains the boundary of B, -1 if A
// excludes the boundary of B, and 0 if the boundaries of A and B cross. | [
"compareBoundary",
"returns",
"+",
"1",
"if",
"this",
"polygon",
"contains",
"the",
"boundary",
"of",
"B",
"-",
"1",
"if",
"A",
"excludes",
"the",
"boundary",
"of",
"B",
"and",
"0",
"if",
"the",
"boundaries",
"of",
"A",
"and",
"B",
"cross",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polygon.go#L898-L906 |
149,986 | golang/geo | s2/polygon.go | containsBoundary | func (p *Polygon) containsBoundary(o *Polygon) bool {
for _, l := range o.loops {
if p.compareBoundary(l) <= 0 {
return false
}
}
return true
} | go | func (p *Polygon) containsBoundary(o *Polygon) bool {
for _, l := range o.loops {
if p.compareBoundary(l) <= 0 {
return false
}
}
return true
} | [
"func",
"(",
"p",
"*",
"Polygon",
")",
"containsBoundary",
"(",
"o",
"*",
"Polygon",
")",
"bool",
"{",
"for",
"_",
",",
"l",
":=",
"range",
"o",
".",
"loops",
"{",
"if",
"p",
".",
"compareBoundary",
"(",
"l",
")",
"<=",
"0",
"{",
"return",
"false... | // containsBoundary reports whether this polygon contains the entire boundary of B. | [
"containsBoundary",
"reports",
"whether",
"this",
"polygon",
"contains",
"the",
"entire",
"boundary",
"of",
"B",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polygon.go#L909-L916 |
149,987 | golang/geo | s2/polygon.go | containsNonCrossingBoundary | func (p *Polygon) containsNonCrossingBoundary(o *Loop, reverse bool) bool {
var inside bool
for _, l := range p.loops {
x := l.containsNonCrossingBoundary(o, reverse)
inside = (inside != x)
}
return inside
} | go | func (p *Polygon) containsNonCrossingBoundary(o *Loop, reverse bool) bool {
var inside bool
for _, l := range p.loops {
x := l.containsNonCrossingBoundary(o, reverse)
inside = (inside != x)
}
return inside
} | [
"func",
"(",
"p",
"*",
"Polygon",
")",
"containsNonCrossingBoundary",
"(",
"o",
"*",
"Loop",
",",
"reverse",
"bool",
")",
"bool",
"{",
"var",
"inside",
"bool",
"\n",
"for",
"_",
",",
"l",
":=",
"range",
"p",
".",
"loops",
"{",
"x",
":=",
"l",
".",
... | // containsNonCrossingBoundary reports whether polygon A contains the boundary of
// loop B. Shared edges are handled according to the rule described in loops
// containsNonCrossingBoundary. | [
"containsNonCrossingBoundary",
"reports",
"whether",
"polygon",
"A",
"contains",
"the",
"boundary",
"of",
"loop",
"B",
".",
"Shared",
"edges",
"are",
"handled",
"according",
"to",
"the",
"rule",
"described",
"in",
"loops",
"containsNonCrossingBoundary",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polygon.go#L931-L938 |
149,988 | golang/geo | s2/polygon.go | excludesNonCrossingShells | func (p *Polygon) excludesNonCrossingShells(o *Polygon) bool {
for _, l := range o.loops {
if l.IsHole() {
continue
}
if p.containsNonCrossingBoundary(l, false) {
return false
}
}
return true
} | go | func (p *Polygon) excludesNonCrossingShells(o *Polygon) bool {
for _, l := range o.loops {
if l.IsHole() {
continue
}
if p.containsNonCrossingBoundary(l, false) {
return false
}
}
return true
} | [
"func",
"(",
"p",
"*",
"Polygon",
")",
"excludesNonCrossingShells",
"(",
"o",
"*",
"Polygon",
")",
"bool",
"{",
"for",
"_",
",",
"l",
":=",
"range",
"o",
".",
"loops",
"{",
"if",
"l",
".",
"IsHole",
"(",
")",
"{",
"continue",
"\n",
"}",
"\n",
"if... | // excludesNonCrossingShells reports wheterh given two polygons A and B such that the
// boundary of A does not cross any loop of B, if A excludes all shell boundaries of B. | [
"excludesNonCrossingShells",
"reports",
"wheterh",
"given",
"two",
"polygons",
"A",
"and",
"B",
"such",
"that",
"the",
"boundary",
"of",
"A",
"does",
"not",
"cross",
"any",
"loop",
"of",
"B",
"if",
"A",
"excludes",
"all",
"shell",
"boundaries",
"of",
"B",
... | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polygon.go#L942-L952 |
149,989 | golang/geo | s2/polygon.go | excludesNonCrossingComplementShells | func (p *Polygon) excludesNonCrossingComplementShells(o *Polygon) bool {
// Special case to handle the complement of the empty or full polygons.
if o.IsEmpty() {
return !p.IsFull()
}
if o.IsFull() {
return true
}
// Otherwise the complement of B may be obtained by inverting loop(0) and
// then swapping the ... | go | func (p *Polygon) excludesNonCrossingComplementShells(o *Polygon) bool {
// Special case to handle the complement of the empty or full polygons.
if o.IsEmpty() {
return !p.IsFull()
}
if o.IsFull() {
return true
}
// Otherwise the complement of B may be obtained by inverting loop(0) and
// then swapping the ... | [
"func",
"(",
"p",
"*",
"Polygon",
")",
"excludesNonCrossingComplementShells",
"(",
"o",
"*",
"Polygon",
")",
"bool",
"{",
"// Special case to handle the complement of the empty or full polygons.",
"if",
"o",
".",
"IsEmpty",
"(",
")",
"{",
"return",
"!",
"p",
".",
... | // excludesNonCrossingComplementShells reports whether given two polygons A and B
// such that the boundary of A does not cross any loop of B, if A excludes all
// shell boundaries of the complement of B. | [
"excludesNonCrossingComplementShells",
"reports",
"whether",
"given",
"two",
"polygons",
"A",
"and",
"B",
"such",
"that",
"the",
"boundary",
"of",
"A",
"does",
"not",
"cross",
"any",
"loop",
"of",
"B",
"if",
"A",
"excludes",
"all",
"shell",
"boundaries",
"of",... | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polygon.go#L957-L982 |
149,990 | golang/geo | s2/polygon.go | anyLoopContains | func (p *Polygon) anyLoopContains(o *Loop) bool {
for _, l := range p.loops {
if l.Contains(o) {
return true
}
}
return false
} | go | func (p *Polygon) anyLoopContains(o *Loop) bool {
for _, l := range p.loops {
if l.Contains(o) {
return true
}
}
return false
} | [
"func",
"(",
"p",
"*",
"Polygon",
")",
"anyLoopContains",
"(",
"o",
"*",
"Loop",
")",
"bool",
"{",
"for",
"_",
",",
"l",
":=",
"range",
"p",
".",
"loops",
"{",
"if",
"l",
".",
"Contains",
"(",
"o",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
... | // anyLoopContains reports whether any loop in this polygon contains the given loop. | [
"anyLoopContains",
"reports",
"whether",
"any",
"loop",
"in",
"this",
"polygon",
"contains",
"the",
"given",
"loop",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polygon.go#L985-L992 |
149,991 | golang/geo | s2/polygon.go | anyLoopIntersects | func (p *Polygon) anyLoopIntersects(o *Loop) bool {
for _, l := range p.loops {
if l.Intersects(o) {
return true
}
}
return false
} | go | func (p *Polygon) anyLoopIntersects(o *Loop) bool {
for _, l := range p.loops {
if l.Intersects(o) {
return true
}
}
return false
} | [
"func",
"(",
"p",
"*",
"Polygon",
")",
"anyLoopIntersects",
"(",
"o",
"*",
"Loop",
")",
"bool",
"{",
"for",
"_",
",",
"l",
":=",
"range",
"p",
".",
"loops",
"{",
"if",
"l",
".",
"Intersects",
"(",
"o",
")",
"{",
"return",
"true",
"\n",
"}",
"\n... | // anyLoopIntersects reports whether any loop in this polygon intersects the given loop. | [
"anyLoopIntersects",
"reports",
"whether",
"any",
"loop",
"in",
"this",
"polygon",
"intersects",
"the",
"given",
"loop",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polygon.go#L995-L1002 |
149,992 | golang/geo | s2/polygon.go | encode | func (p *Polygon) encode(e *encoder) {
if p.numVertices == 0 {
p.encodeCompressed(e, maxLevel, nil)
return
}
// Convert all the polygon vertices to XYZFaceSiTi format.
vs := make([]xyzFaceSiTi, 0, p.numVertices)
for _, l := range p.loops {
vs = append(vs, l.xyzFaceSiTiVertices()...)
}
// Computes a histo... | go | func (p *Polygon) encode(e *encoder) {
if p.numVertices == 0 {
p.encodeCompressed(e, maxLevel, nil)
return
}
// Convert all the polygon vertices to XYZFaceSiTi format.
vs := make([]xyzFaceSiTi, 0, p.numVertices)
for _, l := range p.loops {
vs = append(vs, l.xyzFaceSiTiVertices()...)
}
// Computes a histo... | [
"func",
"(",
"p",
"*",
"Polygon",
")",
"encode",
"(",
"e",
"*",
"encoder",
")",
"{",
"if",
"p",
".",
"numVertices",
"==",
"0",
"{",
"p",
".",
"encodeCompressed",
"(",
"e",
",",
"maxLevel",
",",
"nil",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"// C... | // encode only supports lossless encoding and not compressed format. | [
"encode",
"only",
"supports",
"lossless",
"encoding",
"and",
"not",
"compressed",
"format",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polygon.go#L1022-L1065 |
149,993 | golang/geo | s2/polygon.go | encodeLossless | func (p *Polygon) encodeLossless(e *encoder) {
e.writeInt8(encodingVersion)
e.writeBool(true) // a legacy c++ value. must be true.
e.writeBool(p.hasHoles)
e.writeUint32(uint32(len(p.loops)))
if e.err != nil {
return
}
if len(p.loops) > maxEncodedLoops {
e.err = fmt.Errorf("too many loops (%d; max is %d)", l... | go | func (p *Polygon) encodeLossless(e *encoder) {
e.writeInt8(encodingVersion)
e.writeBool(true) // a legacy c++ value. must be true.
e.writeBool(p.hasHoles)
e.writeUint32(uint32(len(p.loops)))
if e.err != nil {
return
}
if len(p.loops) > maxEncodedLoops {
e.err = fmt.Errorf("too many loops (%d; max is %d)", l... | [
"func",
"(",
"p",
"*",
"Polygon",
")",
"encodeLossless",
"(",
"e",
"*",
"encoder",
")",
"{",
"e",
".",
"writeInt8",
"(",
"encodingVersion",
")",
"\n",
"e",
".",
"writeBool",
"(",
"true",
")",
"// a legacy c++ value. must be true.",
"\n",
"e",
".",
"writeBo... | // encodeLossless encodes the polygon's Points as float64s. | [
"encodeLossless",
"encodes",
"the",
"polygon",
"s",
"Points",
"as",
"float64s",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polygon.go#L1068-L1087 |
149,994 | golang/geo | s2/polygon.go | Decode | func (p *Polygon) Decode(r io.Reader) error {
d := &decoder{r: asByteReader(r)}
version := int8(d.readUint8())
var dec func(*decoder)
switch version {
case encodingVersion:
dec = p.decode
case encodingCompressedVersion:
dec = p.decodeCompressed
default:
return fmt.Errorf("unsupported version %d", version)
... | go | func (p *Polygon) Decode(r io.Reader) error {
d := &decoder{r: asByteReader(r)}
version := int8(d.readUint8())
var dec func(*decoder)
switch version {
case encodingVersion:
dec = p.decode
case encodingCompressedVersion:
dec = p.decodeCompressed
default:
return fmt.Errorf("unsupported version %d", version)
... | [
"func",
"(",
"p",
"*",
"Polygon",
")",
"Decode",
"(",
"r",
"io",
".",
"Reader",
")",
"error",
"{",
"d",
":=",
"&",
"decoder",
"{",
"r",
":",
"asByteReader",
"(",
"r",
")",
"}",
"\n",
"version",
":=",
"int8",
"(",
"d",
".",
"readUint8",
"(",
")"... | // Decode decodes the Polygon. | [
"Decode",
"decodes",
"the",
"Polygon",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/polygon.go#L1112-L1126 |
149,995 | golang/geo | s2/rect.go | RectFromLatLng | func RectFromLatLng(p LatLng) Rect {
return Rect{
Lat: r1.Interval{p.Lat.Radians(), p.Lat.Radians()},
Lng: s1.Interval{p.Lng.Radians(), p.Lng.Radians()},
}
} | go | func RectFromLatLng(p LatLng) Rect {
return Rect{
Lat: r1.Interval{p.Lat.Radians(), p.Lat.Radians()},
Lng: s1.Interval{p.Lng.Radians(), p.Lng.Radians()},
}
} | [
"func",
"RectFromLatLng",
"(",
"p",
"LatLng",
")",
"Rect",
"{",
"return",
"Rect",
"{",
"Lat",
":",
"r1",
".",
"Interval",
"{",
"p",
".",
"Lat",
".",
"Radians",
"(",
")",
",",
"p",
".",
"Lat",
".",
"Radians",
"(",
")",
"}",
",",
"Lng",
":",
"s1"... | // RectFromLatLng constructs a rectangle containing a single point p. | [
"RectFromLatLng",
"constructs",
"a",
"rectangle",
"containing",
"a",
"single",
"point",
"p",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/rect.go#L45-L50 |
149,996 | golang/geo | s2/rect.go | Lo | func (r Rect) Lo() LatLng {
return LatLng{s1.Angle(r.Lat.Lo) * s1.Radian, s1.Angle(r.Lng.Lo) * s1.Radian}
} | go | func (r Rect) Lo() LatLng {
return LatLng{s1.Angle(r.Lat.Lo) * s1.Radian, s1.Angle(r.Lng.Lo) * s1.Radian}
} | [
"func",
"(",
"r",
"Rect",
")",
"Lo",
"(",
")",
"LatLng",
"{",
"return",
"LatLng",
"{",
"s1",
".",
"Angle",
"(",
"r",
".",
"Lat",
".",
"Lo",
")",
"*",
"s1",
".",
"Radian",
",",
"s1",
".",
"Angle",
"(",
"r",
".",
"Lng",
".",
"Lo",
")",
"*",
... | // Lo returns one corner of the rectangle. | [
"Lo",
"returns",
"one",
"corner",
"of",
"the",
"rectangle",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/rect.go#L108-L110 |
149,997 | golang/geo | s2/rect.go | Size | func (r Rect) Size() LatLng {
return LatLng{s1.Angle(r.Lat.Length()) * s1.Radian, s1.Angle(r.Lng.Length()) * s1.Radian}
} | go | func (r Rect) Size() LatLng {
return LatLng{s1.Angle(r.Lat.Length()) * s1.Radian, s1.Angle(r.Lng.Length()) * s1.Radian}
} | [
"func",
"(",
"r",
"Rect",
")",
"Size",
"(",
")",
"LatLng",
"{",
"return",
"LatLng",
"{",
"s1",
".",
"Angle",
"(",
"r",
".",
"Lat",
".",
"Length",
"(",
")",
")",
"*",
"s1",
".",
"Radian",
",",
"s1",
".",
"Angle",
"(",
"r",
".",
"Lng",
".",
"... | // Size returns the size of the Rect. | [
"Size",
"returns",
"the",
"size",
"of",
"the",
"Rect",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/rect.go#L123-L125 |
149,998 | golang/geo | s2/rect.go | Area | func (r Rect) Area() float64 {
if r.IsEmpty() {
return 0
}
capDiff := math.Abs(math.Sin(r.Lat.Hi) - math.Sin(r.Lat.Lo))
return r.Lng.Length() * capDiff
} | go | func (r Rect) Area() float64 {
if r.IsEmpty() {
return 0
}
capDiff := math.Abs(math.Sin(r.Lat.Hi) - math.Sin(r.Lat.Lo))
return r.Lng.Length() * capDiff
} | [
"func",
"(",
"r",
"Rect",
")",
"Area",
"(",
")",
"float64",
"{",
"if",
"r",
".",
"IsEmpty",
"(",
")",
"{",
"return",
"0",
"\n",
"}",
"\n",
"capDiff",
":=",
"math",
".",
"Abs",
"(",
"math",
".",
"Sin",
"(",
"r",
".",
"Lat",
".",
"Hi",
")",
"... | // Area returns the surface area of the Rect. | [
"Area",
"returns",
"the",
"surface",
"area",
"of",
"the",
"Rect",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/rect.go#L128-L134 |
149,999 | golang/geo | s2/rect.go | AddPoint | func (r Rect) AddPoint(ll LatLng) Rect {
if !ll.IsValid() {
return r
}
return Rect{
Lat: r.Lat.AddPoint(ll.Lat.Radians()),
Lng: r.Lng.AddPoint(ll.Lng.Radians()),
}
} | go | func (r Rect) AddPoint(ll LatLng) Rect {
if !ll.IsValid() {
return r
}
return Rect{
Lat: r.Lat.AddPoint(ll.Lat.Radians()),
Lng: r.Lng.AddPoint(ll.Lng.Radians()),
}
} | [
"func",
"(",
"r",
"Rect",
")",
"AddPoint",
"(",
"ll",
"LatLng",
")",
"Rect",
"{",
"if",
"!",
"ll",
".",
"IsValid",
"(",
")",
"{",
"return",
"r",
"\n",
"}",
"\n",
"return",
"Rect",
"{",
"Lat",
":",
"r",
".",
"Lat",
".",
"AddPoint",
"(",
"ll",
... | // AddPoint increases the size of the rectangle to include the given point. | [
"AddPoint",
"increases",
"the",
"size",
"of",
"the",
"rectangle",
"to",
"include",
"the",
"given",
"point",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/rect.go#L137-L145 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.