Skip to content

Commit 3537c3f

Browse files
committed
Internal streamlining
1 parent cc8a54d commit 3537c3f

File tree

8 files changed

+32
-25
lines changed

8 files changed

+32
-25
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: spatstat.linnet
2-
Version: 3.4-0.015
2+
Version: 3.4-0.016
33
Date: 2026-01-01
44
Title: Linear Networks Functionality of the 'spatstat' Family
55
Authors@R: c(person("Adrian", "Baddeley",
@@ -25,7 +25,7 @@ Authors@R: c(person("Adrian", "Baddeley",
2525
person("Ottmar", "Cronie",
2626
role = "ctb"))
2727
Maintainer: Adrian Baddeley <[email protected]>
28-
Depends: R (>= 3.5.0), stats, graphics, grDevices, methods, utils, spatstat.data (>= 3.1-9), spatstat.univar (>= 3.1-5), spatstat.geom (>= 3.6-1.008), spatstat.random (>= 3.4-3), spatstat.explore (>= 3.6-0), spatstat.model (>= 3.5-0.012)
28+
Depends: R (>= 3.5.0), stats, graphics, grDevices, methods, utils, spatstat.data (>= 3.1-9), spatstat.univar (>= 3.1-5), spatstat.geom (>= 3.6-1.022), spatstat.random (>= 3.4-3), spatstat.explore (>= 3.6-0), spatstat.model (>= 3.5-0.012)
2929
Imports: Matrix, spatstat.utils (>= 3.1-5), spatstat.sparse (>= 3.1)
3030
Suggests: goftest, locfit, spatstat (>= 3.4)
3131
Description: Defines types of spatial data on a linear network

NEWS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
CHANGES IN spatstat.linnet VERSION 3.4-0.015
2+
CHANGES IN spatstat.linnet VERSION 3.4-0.016
33

44
OVERVIEW
55

R/linnet.R

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -689,8 +689,7 @@ connected.linnet <- function(X, ..., what=c("labels", "components")) {
689689
verifyclass(X, "linnet")
690690
what <- match.arg(what)
691691
nv <- npoints(vertices(X))
692-
lab0 <- cocoEngine(nv, X$from - 1L, X$to - 1L, "connected.linnet")
693-
lab <- lab0 + 1L
692+
lab <- cocoLabels(nv, X$from, X$to, "connected.linnet")
694693
lab <- factor(as.integer(factor(lab)))
695694
if(what == "labels")
696695
return(lab)
@@ -776,7 +775,7 @@ identify.linnet <- function(x, ...) {
776775
identify(as.psp(x), ...)
777776
}
778777

779-
roadways <- function(X, what=c("labels", "segments", "function")) {
778+
roadways <- function(X, what=c("labels", "segments", "tessellation", "function")) {
780779
verifyclass(X, "linnet")
781780
what <- match.arg(what)
782781
## identify which vertices are just a 'bend' in the road
@@ -789,19 +788,16 @@ roadways <- function(X, what=c("labels", "segments", "function")) {
789788
ok <- bend[ver]
790789
seg <- seg[ok]
791790
ver <- ver[ok]
792-
## match (segment, vertex) pairs with the same vertex
791+
## match (segment, vertex) pairs which have the same vertex
793792
second <- which(duplicated(ver))
794793
first <- uniquemap(ver)[second]
795794
## extract corresponding edges
796795
a <- seg[first]
797796
b <- seg[second]
798797
## Thus edges a[j], b[j] share a common vertex of degree 2, for each j
799798
## Identify equivalence classes
800-
lab0 <- cocoEngine(nsegments(X), a - 1L, b - 1L, "roadways algorithm")
801-
## renumber sequentially
802-
lab <- as.integer(factor(lab0))
803-
# Convert labels to factor
804-
lab <- factor(lab)
799+
lab <- cocoLabels(nsegments(X), a, b, "roadways algorithm")
800+
lab <- as.factor(lab)
805801
##
806802
switch(what,
807803
labels = {
@@ -810,6 +806,13 @@ roadways <- function(X, what=c("labels", "segments", "function")) {
810806
segments = {
811807
result <- as.psp(X) %mark% lab
812808
},
809+
tessellation = {
810+
df <- data.frame(seg=seq_len(nsegments(X)),
811+
t0=0,
812+
t1=1,
813+
tile=lab)
814+
result <- lintess(X, df)
815+
},
813816
"function" = {
814817
f <- function(x,y,seg,tp, ...) { lab[seg] }
815818
result <- linfun(f, X)

R/lintessmakers.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#' Creation of linear tessellations
55
#' and intersections between lintess objects
66
#'
7-
#' $Revision: 1.13 $ $Date: 2025/11/27 07:50:47 $
7+
#' $Revision: 1.14 $ $Date: 2026/01/01 08:00:42 $
88
#'
99

1010
divide.linnet <- local({
@@ -48,8 +48,7 @@ divide.linnet <- local({
4848
iedge <- c(iedge, joined[-njoin])
4949
jedge <- c(jedge, joined[-1L])
5050
}
51-
lab0 <- cocoEngine(nbits, iedge - 1L, jedge - 1L)
52-
lab <- lab0 + 1L
51+
lab <- cocoLabels(nbits, iedge, jedge, "divide.linnet")
5352
lab <- as.integer(factor(lab))
5453
df <- df[,c("seg", "t0", "t1")]
5554
df$tile <- lab

R/lpp.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,8 +685,7 @@ connected.lpp <- function(X, R=Inf, ..., dismantle=TRUE) {
685685
close <- (pairdist(X) <= R)
686686
diag(close) <- FALSE
687687
ij <- which(close, arr.ind=TRUE)
688-
lab0 <- cocoEngine(nv, ij[,1] - 1L, ij[,2] - 1L, "connected.lpp")
689-
lab <- lab0 + 1L
688+
lab <- cocoLabels(nv, ij[,1], ij[,2], "connected.lpp")
690689
# Renumber labels sequentially
691690
lab <- as.integer(factor(lab))
692691
# Convert labels to factor

inst/doc/packagesizes.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ date version nhelpfiles nobjects ndatasets Rlines srclines
4242
"2025-07-24" "3.3-1" 150 328 0 13326 3270
4343
"2025-09-24" "3.3-2" 150 328 0 13356 3270
4444
"2025-11-29" "3.4-0" 160 370 0 14990 3270
45-
"2026-01-01" "3.4-0.015" 161 373 0 15477 3270
45+
"2026-01-01" "3.4-0.016" 161 373 0 15478 3270

inst/info/packagesizes.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ date version nhelpfiles nobjects ndatasets Rlines srclines
4242
"2025-07-24" "3.3-1" 150 328 0 13326 3270
4343
"2025-09-24" "3.3-2" 150 328 0 13356 3270
4444
"2025-11-29" "3.4-0" 160 370 0 14990 3270
45-
"2026-01-01" "3.4-0.015" 161 373 0 15477 3270
45+
"2026-01-01" "3.4-0.016" 161 373 0 15478 3270

man/roadways.Rd

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
any forks in the network.
1010
}
1111
\usage{
12-
roadways(X, what = c("labels", "segments", "function"))
12+
roadways(X, what = c("labels", "segments", "tessellation", "function"))
1313
}
1414
\arguments{
1515
\item{X}{
@@ -47,14 +47,20 @@ roadways(X, what = c("labels", "segments", "function"))
4747
it belongs to. If \code{what="labels"} (the default), the result is a
4848
factor of length equal to \code{nsegments(X)} giving the
4949
classification of segments. If \code{what="segments"}, the result is
50-
a line segment pattern (object of class \code{"psp"}) with marks
51-
indicating the classification. If \code{what="function"}, the result
50+
a line segment pattern (object of class \code{"psp"}) with
51+
factor-valued marks indicating the classification of segments.
52+
If \code{what="tessellation"}, the result is a tessellation of
53+
\code{X} (object of class \code{"lintess"}) in which the tiles of the
54+
tessellation are the roadways.
55+
If \code{what="function"}, the result
5256
is a function of class \code{"linfun"} which can be applied to any
53-
location on the network to determine which roadway it belongs to.
57+
location on the network and returns a categorical value
58+
indicating which roadway the location belongs to.
5459
}
5560
\value{
56-
A factor, or an object of class \code{"psp"}, or a function
57-
of class \code{"linfun"}.
61+
A factor, or an object of class \code{"psp"},
62+
a tessellation of class \code{"lintess"},
63+
or a function of class \code{"linfun"}.
5864
}
5965
\author{
6066
\adrian

0 commit comments

Comments
 (0)