|
DJI Onboard SDK
|
A top-level encapsulation of a DJI drone/FC connected to your OES. More...
#include <DJI_Vehicle.h>
Public Types | |
| enum | STATUS { STATUS_STOPED = 0, STATUS_ON_GND = 1, STATUS_IN_AIR = 2 } |
Public Member Functions | |
| Vehicle (std::string device, uint32_t baudRate, bool threadSupport) | |
| void | obtainCtrlAuthority (VehicleCallBack callback=0, UserData userData=0) |
| Future release. More... | |
| ACKErrorCode | obtainCtrlAuthority (int timeout) |
| Obtain the control authority of the api (blocking call) More... | |
| void | releaseCtrlAuthority (VehicleCallBack callback=0, UserData userData=0) |
| Release the control authority of the api (non-blocking call) More... | |
| ACKErrorCode | releaseCtrlAuthority (int timeout) |
| Release the control authority of the api (blocking call) More... | |
| ACKErrorCode | activate (ActivateData *data, int timeout) |
| Send activation control to your flight controller to check if: a) your application registered in your developer account b) API Control enabled in the Assistant software Proceed to programming if activation successful. More... | |
| ACKErrorCode | getDroneVersion (int timeout) |
| void | activate (ActivateData *data, VehicleCallBack callback=0, UserData userData=0) |
| Send activation request to your flight controller to check if: a) your application registered in your developer account b) API Control enabled in the Assistant software Proceed to programming if activation successful. More... | |
Public Attributes | |
| ProtocolLayer * | protocolLayer |
| DJI_DataSubscription * | subscribe |
| DataBroadcast * | broadcast |
| Control * | control |
| Camera * | camera |
| MFIO * | mfio |
| MobileCommunication * | moc |
| MissionManager * | missionManager |
| HardwareSync * | hardSync |
| CircularBuffer * | circularBuffer |
| void * | nbCallbackFunctions [200] |
| UserData | nbUserData [200] |
| void | getDroneVersion (VehicleCallBack callback=0, UserData userData=0) |
| ActivateData | getAccountData () const |
| void | setAccountData (const ActivateData &value) |
| void | setVersion (const Version &value) |
| Version | getFwVersion () const |
| char * | getHwVersion () const |
| char * | getHwSerialNum () const |
| void | setKey (const char *key) |
| void | setStopCond (bool stopCond) |
| bool | getStopCond () |
| void | setLastReceivedFrame (RecvContainer recvFrame) |
| RecvContainer | getLastReceivedFrame () |
| void | processReceivedData (RecvContainer receivedFrame) |
| This function takes a frame and calls the right handlers/functions based on the nature of the frame (ack, blocking, etc.) More... | |
| void | callbackPoll () |
| User sets this to true in order to enable Callback thread with Non blocking calls. More... | |
| int | callbackIdIndex () |
A top-level encapsulation of a DJI drone/FC connected to your OES.
This class instantiates objects for all features your drone/FC supports. Create a Vechile object in your code and you will have access to the entire DJI OSDK API.
| Vehicle::Vehicle | ( | std::string | device, |
| uint32_t | baudRate, | ||
| bool | threadSupport | ||
| ) |
TODO init flight class
| ACKErrorCode Vehicle::activate | ( | ActivateData * | data, |
| int | timeout | ||
| ) |
Send activation control to your flight controller to check if:
a) your application registered in your developer account
b) API Control enabled in the Assistant software
Proceed to programming if activation successful.
Using function prototype II of send
| void Vehicle::activate | ( | ActivateData * | data, |
| VehicleCallBack | callback = 0 , |
||
| UserData | userData = 0 |
||
| ) |
Send activation request to your flight controller to check if:
a) your application registered in your developer account
b) API Control enabled in the Assistant software
Proceed to programming if activation successful.
Using function prototype II of send
| void Vehicle::callbackPoll | ( | ) |
User sets this to true in order to enable Callback thread with Non blocking calls.
If Head = Tail, there is no data in the buffer, do not call cbPop.
| ActivateData Vehicle::getAccountData | ( | ) | const |
Get Activation information
| ACKErrorCode Vehicle::getDroneVersion | ( | int | timeout | ) |
Finally, we print stuff out.
| void Vehicle::getDroneVersion | ( | VehicleCallBack | callback = 0 , |
| UserData | userData = 0 |
||
| ) |
Get aircraft version.
| void Vehicle::obtainCtrlAuthority | ( | VehicleCallBack | callback = 0 , |
| UserData | userData = 0 |
||
| ) |
Future release.
Obtain the control authority of the api (non-blocking call)
| callback | callback function |
| userData | user data (void ptr) |
| ACKErrorCode Vehicle::obtainCtrlAuthority | ( | int | timeout | ) |
Obtain the control authority of the api (blocking call)
| timeout | time to wait for ACK |
| void Vehicle::processReceivedData | ( | RecvContainer | receivedFrame | ) |
This function takes a frame and calls the right handlers/functions based on the nature of the frame (ack, blocking, etc.)
| receivedFrame | RecvContainer populated by the protocolLayer |
| void Vehicle::releaseCtrlAuthority | ( | VehicleCallBack | callback = 0 , |
| UserData | userData = 0 |
||
| ) |
Release the control authority of the api (non-blocking call)
| callback | callback function |
| userData | user data (void ptr) |
| ACKErrorCode Vehicle::releaseCtrlAuthority | ( | int | timeout | ) |
Release the control authority of the api (blocking call)
| timeout | time to wait for ACK |
| void Vehicle::setLastReceivedFrame | ( | RecvContainer | recvFrame | ) |
Storage for last received packet: accessors
| void Vehicle::setVersion | ( | const Version & | value | ) |
Set SDK version.


OAuth 2.0 authentication with Facebook/Google
OAuth 2.0 is an authorization framework that enables you to authenticate a user via a trusted third party. A brief summary of the protocol flow is as follows:
- The user wants to log in to a server (e.g. your Kitura application).
- The user is redirected to the OAuth 2.0 provider (e.g. Facebook/Google).
- The user authenticates with the OAuth 2.0 provider and is given a single use access code.
- The user is sent back to the server and provides them with the access code.
- The server sends the access code to the OAuth 2.0 provider and is given an access token.
- The server uses the access token to request the user's information and authenticate them.
If you would like a more in-depth explanation of OAuth 2.0, you can read this guide by DigitalOcean.
Kitura supports OAuth 2.0 authentication using plugins for the Kitura-Credentials authentication framework. In this guide, we show you how to use the Kitura-CredentialsGoogle and the Kitura-CredentialsFacebook plugins. Because we are authenticating using a third party, the user does not need to create a new account for our service and we don't need to handle their username and password.
This guide describes how to implement the OAuth 2.0 flow for a client accessing the server via a web browser.
For a mobile application, the user must authenticate themselves on the device, send the access token to the server and have the token authenticated using a Credentials token plugin. We will not cover the mobile application flow in this guide.
Step 1: Create your third party OAuth 2.0 application
For this guide we need a third party OAuth 2.0 provider who will authenticate the user. Select either Facebook or Google below and we will show you how to create the OAuth 2.0 provider for that platform.
The code examples for the rest of the guide will be updated to match the selected OAuth 2.0 provider.
Log in/sign up to Facebook developers.
Create a new Facebook App with a name of your choice.
From the dashboard, add the Facebook login product.
Inside Facebook login settings, add http://localhost:8080/oauth2/facebook to the Valid OAuth Redirect URIs.
Inside the App settings, note down the App ID and App Secret. We will need them later.
Follow the Google Setting up OAuth 2.0 guide.
Once you have created your client ID, add http://localhost:8080/oauth2/google to your authorized redirect URIs.
Note down the client ID and client secret. We will need them later.
Step 2: Create the OAuth 2.0 routes
In this guide we are going to create three Kitura routes:
A log in route, where we authenticate the user
A protected route, which can only be accessed by a user who is logged in
A log out route, where we revoke the users credentials
In this step we will create the framework for our protected and log out routes.
If you don't have a server, follow our Create a server guide.
Firstly, open your Application.swift file in your default text editor (or Xcode if you prefer):
open Sources/Application/Application.swift
Inside the postInit() function add:
initializeOAuth2Routes(app: self)
Next, create a new file, called OAuth2Routes.swift, to contain the framework for our routes code:
touch Sources/Application/Routes/OAuth2Routes.swift
Open your OAuth2Routes.swift file:
open Sources/Application/Routes/OAuth2Routes.swift
Inside this file, add the framework for our routes code:
func initializeOAuth2Routes(app: App) {
// Configure Credentials and session here
app.router.get("/oauth2/protected") { request, response, next in
// Check the user is authenticated here
next()
}
app.router.get("/oauth2/logout") { request, response, next in
// Log out user here
next()
}
}
Step 3: Import dependencies
Add Kitura-Credentials, Kitura-CredentialsFacebook and Kitura-Session to the dependencies in the Package.swift file.
Inside the file which defines the routes, OAuth2Routes.swift, import the Credentials, CredentialsFacebook and KituraSession packages:
import Credentials
import CredentialsFacebook
import KituraSession
Add Kitura-Credentials, Kitura-CredentialsGoogle and Kitura-Session to the dependencies in the Package.swift file.
Inside the file which defines the routes, OAuth2Routes.swift, import Credentials, CredentialsGoogle and KituraSession:
import Credentials
import CredentialsGoogle
import KituraSession
Step 4: Set up a session
Kitura-Credentials requires a session to be set up on the protected routes. This will use cookies to keep the user logged in after the initial authentication.
let session = Session(secret: "AuthSecret", cookie: [CookieParameter.name("Kitura-Auth-cookie")])
app.router.all("/oauth2", middleware: session)
Step 5: Configure your Credentials middleware
We need to initialize an instance of our Credentials plugin using the id and secret from the OAuth 2.0 application we created in step 1.
We add the following code to our initializeOAuth2Routes function, substituting in our own id and secret:
let fbClientId = "<Your Facebook App ID>"
let fbClientSecret = "<Your Facebook App Secret>"
let fbCallbackUrl = "http://localhost:8080/oauth2/facebook"
let fbCredentials = CredentialsFacebook(clientId: fbClientId, clientSecret: fbClientSecret, callbackUrl: fbCallbackUrl)
let googleClientId = "<Your Google Client Id>"
let googleClientSecret = "<Your Google Client Secret>"
let googleCallbackUrl = "http://localhost:8080/oauth2/google"
let googleCredentials = CredentialsGoogle(clientId: googleClientId, clientSecret: googleClientSecret, callbackUrl: googleCallbackUrl)
Step 6: Register your Credentials plugin
We need to register our plugin credentials to a Credentials middleware.
let fbCredMiddleware = Credentials(options: ["successRedirect": "/oauth2/protected"])
fbCredMiddleware.register(plugin: fbCredentials)
Next, we need to register our Credentials middleware on our login route.
When a user hits this route, they will be redirected to the OAuth 2.0 provider.
When the user is sent back to this route, their access code will be authenticated.
If they successfully authenticate, they will be redirected to the "successRedirect" we set on our middleware.
app.router.get("/oauth2/facebook", handler: fbCredMiddleware.authenticate(credentialsType: fbCredentials.name))
let googleCredMiddleware = Credentials(options: ["successRedirect": "/oauth2/protected"])
googleCredMiddleware.register(plugin: googleCredentials)
Next, we need to register our Credentials middleware on our login route.
When a user hits this route, they will be redirected to the OAuth 2.0 provider.
When the user is sent back to this route, their access code with be authenticated.
If they successfully authenticate, they will be redirected to the "successRedirect" we set on our middleware.
app.router.get("/oauth2/google", handler: googleCredMiddleware.authenticate(credentialsType: googleCredentials.name))
Step 7: Check if a user is logged in
Once a user successfully authenticates, they will have a userProfile attached to all their requests via the session we set up in step 4.
Inside our oauth2/protected route, we want to check if they have logged in using the userProfile.
guard let user = request.userProfile else {
return try response.send("Not authorized to view this route").end()
}
response.send("Hello \(user.displayName)")
The user profile contains information about the user such as how they authenticated, their unique id and their displayName.
Step 8: Logging out a user
The user will remain logged in as long as their cookie provides a valid userProfile. We can log out a user by invalidating the cookie with the session store or by setting the userProfile to nil.
Inside our logout route handler, call the Credentials.logOut function:
fbCredMiddleware.logOut(request: request)
googleCredMiddleware.logOut(request: request)
Our completed OAuth 2.0 routes should now look as follows:
import Credentials
import CredentialsFacebook
import KituraSession
func initializeOAuth2Routes(app: App) {
let session = Session(secret: "AuthSecret", cookie: [CookieParameter.name("Kitura-Auth-cookie")])
app.router.all("/oauth2", middleware: session)
let fbClientId = "<Your Facebook App ID>"
let fbClientSecret = "<Your Facebook App Secret>"
let fbCallbackUrl = "http://localhost:8080/oauth2/facebook"
let fbCredentials = CredentialsFacebook(clientId: fbClientId, clientSecret: fbClientSecret, callbackUrl: fbCallbackUrl)
let fbCredMiddleware = Credentials(options: ["successRedirect": "/oauth2/protected"])
fbCredMiddleware.register(plugin: fbCredentials)
app.router.get("/oauth2/facebook", handler: fbCredMiddleware.authenticate(credentialsType: fbCredentials.name))
app.router.get("/oauth2/protected") { request, response, next in
guard let user = request.userProfile else {
return try response.send("Not authorized to view this route").end()
}
response.send("Hello \(user.displayName)")
next()
}
app.router.get("/oauth2/logout") { request, response, next in
fbCredMiddleware.logOut(request: request)
next()
}
}
import Credentials
import CredentialsGoogle
import KituraSession
func initializeOAuth2Routes(app: App) {
let session = Session(secret: "AuthSecret", cookie: [CookieParameter.name("Kitura-Auth-cookie")])
app.router.all("/oauth2", middleware: session)
let googleClientId = "<Your Google Client Id>"
let googleClientSecret = "<Your Google Client Secret>"
let googleCallbackUrl = "http://localhost:8080/oauth2/google"
let googleCredentials = CredentialsGoogle(clientId: googleClientId, clientSecret: googleClientSecret, callbackUrl: googleCallbackUrl)
let googleCredMiddleware = Credentials(options: ["successRedirect": "/oauth2/protected"])
googleCredMiddleware.register(plugin: googleCredentials)
app.router.get("/oauth2/google", handler: googleCredMiddleware.authenticate(credentialsType: googleCredentials.name))
app.router.get("/oauth2/protected") { request, response, next in
guard let user = request.userProfile else {
return try response.send("Not authorized to view this route").end()
}
response.send("Hello \(user.displayName)")
next()
}
app.router.get("/oauth2/logout") { request, response, next in
googleCredMiddleware.logOut(request: request)
next()
}
}
Step 9: Testing our OAuth 2.0 authentication system
Now that everything is set up we can test logging in using OAuth 2.0.
Start your server and open your browser at:
http://localhost:8080/oauth2/protected
We will be sent our unauthorized message since we haven't logged in yet.
We authenticate by going to the login route for our plugin:
This will send you to the OAuth 2.0 provider who will request that you log in and provide access to our server.
Once you complete this you will be sent back to our server which will redirect you to our "/oauth2/protected" route.
This time you will be authenticated and will see a welcome message.
As long as your session persists, you can return to http://localhost:8080/oauth2/protected and will be allowed access.
Congratulations! You have just set up OAuth 2.0 authentication on your Kitura server.


Chapter 23 Vector and matrix algebra
23.1 Heights and foot lengths again
Earlier, we investigated some data on predicting the height of a person from the length of their foot. The data were in http://ritsokiguess.site/datafiles/heightfoot.csv.
Read in and display (some of) the data.
In your regression course, you learned (or will learn) the matrix formulation of the least squares estimates of intercept and slope. This produces a vector \(\hat\beta\) containing estimates of both the intercept and the slope, from the formula
\[ \hat\beta = (X^T X)^{-1} X^T y, \]
where:
- \(X\) is a matrix containing a column of 1s followed by all the columns of explanatory variables
- \(X^T\) denotes the (matrix) transpose of \(X\)
- \(M^{-1}\) denotes the inverse of the matrix \(M\)
- \(y\) denotes the column of response variable values.
Use the formula above to obtain the least squares estimates of intercepts and slope for this regression, using R’s vector-matrix algebra. Hint: you are advised to do the calculation in steps, or else it will be very hard to read, and hard for the grader to check that it is correct.
- Verify that your calculation is correct by running the regression.
My solutions follow:
23.2 Heights and foot lengths again
Earlier, we investigated some data on predicting the height of a person from the length of their foot. The data were in http://ritsokiguess.site/datafiles/heightfoot.csv.
- Read in and display (some of) the data.
Solution
Copy what you did before:
##
## ── Column specification ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## cols(
## height = col_double(),
## foot = col_double()
## )
## # A tibble: 33 x 2
## height foot
## <dbl> <dbl>
## 1 66.5 27
## 2 73.5 29
## 3 70 25.5
## 4 71 27.9
## 5 73 27
## 6 71 26
## 7 71 29
## 8 69.5 27
## 9 73 29
## 10 71 27
## # … with 23 more rows
\(\blacksquare\)
- In your regression course, you learned (or will learn) the matrix formulation of the least squares estimates of intercept and slope. This produces a vector \(\hat\beta\) containing estimates of both the intercept and the slope, from the formula
\[ \hat\beta = (X^T X)^{-1} X^T y, \]
where:
- \(X\) is a matrix containing a column of 1s followed by all the columns of explanatory variables
- \(X^T\) denotes the (matrix) transpose of \(X\)
- \(M^{-1}\) denotes the inverse of the matrix \(M\)
- \(y\) denotes the column of response variable values.
Use the formula above to obtain the least squares estimates of intercepts and slope for this regression, using R’s vector-matrix algebra. Hint: you are advised to do the calculation in steps, or else it will be very hard to read, and hard for the grader to check that it is correct.
Solution
There is some setup first: we have to get hold of \(X\) and \(y\) from the data as a matrix and a vector respectively. I would use tidyverse ideas to do this, and then turn them into a matrix at the end, which I think is best. Don’t forget to create a column of 1s to make the first column of \(X\)
## one foot
## [1,] 1 27.0
## [2,] 1 29.0
## [3,] 1 25.5
## [4,] 1 27.9
## [5,] 1 27.0
## [6,] 1 26.0
(head
displays the first six rows, or else you’ll be displaying all 33, which is too many.)
Another approach is this:
## [,1] [,2]
## [1,] 1 27.0
## [2,] 1 29.0
## [3,] 1 25.5
## [4,] 1 27.9
## [5,] 1 27.0
## [6,] 1 26.0
Note that the recycling rules mean that a column with only one value in it will be repeated to the length of the other one, and so this is better than working out how many observations there are and repeating 1
that many times.
The choice here is whether to use tidyverse stuff and turn into a matrix at the end, or make a matrix at the start (which is what cbind
from base R is doing). I don’t believe you’ve seen that in this course, so you ought to cite your source if you go that way.
The simplest choice for making \(y\) is this:
## [1] 66.5 73.5 70.0 71.0 73.0 71.0 71.0 69.5 73.0 71.0 69.0 69.0 73.0 75.0 73.0 72.0 69.0 68.0 72.5 78.0 79.0 71.0 74.0 66.0 71.0 71.0 71.0 84.0 77.0 72.0 70.0 76.0 68.0
This also works:
## [1] 66.5 73.5 70.0 71.0 73.0 71.0 71.0 69.5 73.0 71.0 69.0 69.0 73.0 75.0 73.0 72.0 69.0 68.0 72.5 78.0 79.0 71.0 74.0 66.0 71.0 71.0 71.0 84.0 77.0 72.0 70.0 76.0 68.0
(remembering that you don’t want to have anything that’s a dataframe), or this:
## height
## [1,] 66.5
## [2,] 73.5
## [3,] 70.0
## [4,] 71.0
## [5,] 73.0
## [6,] 71.0
remembering that a (column) vector and a 1-column matrix are the same thing as R is concerned.
Now we want to construct some things. I would go at it this way, rather than trying to do everything at once (if you do, you will either get lost now, or in six months when you try to figure out what you did):
## [,1]
## [1,] 34.336335
## [2,] 1.359062
The intercept is 34.33 and the slope is 1.36.
These compute, respectively, \(X^T\), \(X^T X\), the inverse of that, \(X^T y\) and \(\hat\beta\). Expect credit for laying out your calculation clearly.
Extra: the value of this formula is that it applies no matter whether you have one \(x\)-variable, as here (or in the windmill data), or whether you have a lot (as in the asphalt data). In either case, \(\hat\beta\) contains the estimate of the intercept followed by all the slope estimates, however many there are. There are also matrix formulas that tell you how the slopes or the residuals will change if you remove one observation or one explanatory variable, so that something like step
will work very efficiently, and calculations for leverages likewise.
\(\blacksquare\)
- Verify that your calculation is correct by running the regression.
Solution
The usual lm
:
##
## Call:
## lm(formula = height ~ foot, data = hf)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.7491 -1.3901 -0.0310 0.8918 12.9690
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 34.3363 9.9541 3.449 0.001640 **
## foot 1.3591 0.3581 3.795 0.000643 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.102 on 31 degrees of freedom
## Multiple R-squared: 0.3173, Adjusted R-squared: 0.2952
## F-statistic: 14.41 on 1 and 31 DF, p-value: 0.0006428
The same.
Extra: in this “well-conditioned” case,35 it makes no difference, but if \(X^T X\) is almost singular, so that it almost doesn’t have an inverse (for example, some of your explanatory variables are highly correlated with each other), you can get into trouble. Regression calculations in practice use something more sophisticated like the singular value decomposition of \(X^TX\) to diagnose whether \(X^TX\) is actually singular or almost so, which from a numerical point of view is almost as bad, and to produce a sensible answer in that case.
I guess I should try to make up one where it struggles. Let me do one with two \(x\)’s that are strongly correlated:
d <- tribble(
~x1, ~x2, ~y,
10, 20, 55,
11, 19.0001, 60,
12, 17.9999, 61,
13, 17.0001, 64,
14, 15.9998, 66,
15, 15.0001, 67
)
d
## # A tibble: 6 x 3
## x1 x2 y
## <dbl> <dbl> <dbl>
## 1 10 20 55
## 2 11 19.0 60
## 3 12 18.0 61
## 4 13 17.0 64
## 5 14 16.0 66
## 6 15 15.0 67
x2
is almost exactly equal to 30 minus x1
. What’s the right answer?
##
## Call:
## lm(formula = y ~ x1 + x2, data = d)
##
## Residuals:
## 1 2 3 4 5 6
## -1.37530 1.26859 0.03118 0.63549 0.43765 -0.99760
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -11837.3 138685.6 -0.085 0.937
## x1 398.0 4622.9 0.086 0.937
## x2 395.7 4622.8 0.086 0.937
##
## Residual standard error: 1.303 on 3 degrees of freedom
## Multiple R-squared: 0.9485, Adjusted R-squared: 0.9141
## F-statistic: 27.61 on 2 and 3 DF, p-value: 0.0117
## (Intercept) x1 x2
## -11837.2938 398.0000 395.6835
You should be right away suspicious here: the R-squared is high, but neither of the explanatory variables are significant! (This actually means that you can remove one of them, either one.) The standard errors are also suspiciously large, never a good sign. If you’ve done C67, you might be thinking about variance inflation factors here:
## x1 x2
## 220326265 220326265
These are both huge (greater than 5 or 10 or whatever guideline you use), indicating that they are highly correlated with each other (as we know they are).
All right, how does the matrix algebra work? This is just the same as before:
## one x1 x2
## [1,] 1 10 20.0000
## [2,] 1 11 19.0001
## [3,] 1 12 17.9999
## [4,] 1 13 17.0001
## [5,] 1 14 15.9998
## [6,] 1 15 15.0001
and then
## [,1]
## one -11837.2051
## x1 397.9970
## x2 395.6805
These answers are actually noticeably different from the right answers (with a few more decimals here):
## (Intercept) x1 x2
## -11837.2938 398.0000 395.6835
One way of finding out how nearly singular \(X^TX\) is is to look at its eigenvalues. You’ll recall that a singular matrix has one or more zero eigenvalues:
## eigen() decomposition
## $values
## [1] 2.781956e+03 3.404456e+01 8.805997e-11
##
## $vectors
## [,1] [,2] [,3]
## [1,] -0.04643281 -0.00782885 0.99889074
## [2,] -0.57893109 -0.81469635 -0.03329647
## [3,] -0.81405331 0.57983495 -0.03329628
The third eigenvalue is \(8.8 \times 10^{-11}\), which is very close to zero, especially compared to the other two, which are 34 and over two thousand. This is a very nearly singular matrix, and hence \((X^TX)^{-1}\) is very close to not existing at all, and that would mean that you couldn’t even compute the intercept and slope estimates, never mind hope to get close to the right answer.
\(\blacksquare\)
Which in this case means that the column of 1s and the actual x values are not strongly correlated, which means that the x-values vary enough.↩


Licenseplates.tv carefully evaluates every special request for license plates from idividuals or corporations. We cater to all of our customers needs. No job is too big or too small. Either it be to replicate an old license plate passed down from generations, or to simply change the year on a license plate for a more up-to-date appeal.
Our Team of dedicated professionals work diligently to provide the most outstanding craftsmanship any one can offer. We take pride in providing excellent service to all our customers.
Please see below at some of the work that we have done in the past.
Special Request by customers:
ANTIQUE ITALIAN LICENSE PLATES, REPLICATED FROM OLD PHOTOS PROVIDED BY CUSTOMERS
COMMEMORATIVE LICENSE PLATE
FERRARI WORLLLD - ABU DHABI
REPLICA OF A1936 MAINE
STATE POLICE LICENSE PLATE
SPECIALTY LICENSE PLATE FOR CARS THE RIDE
IN DISNEY CALIFORNIA
If you have a plate you would like us to make please contact us:


Before Change
// invalid numpy calculations that may be the result of out of
// bounds on axis with finite allowed intervals such as geo
// projections i.e. Mollweide.
with np.errstate(invalid="ignore"):
try:
ds1 = self._get_pixel_distance_along_axis(
interval_expanded[0], -0.5)
except Exception:
cbook._warn_external("Unable to find pixel distance "
"along axis for interval padding of "
"ticks; assuming no interval "
"padding needed.")
ds1 = 0.0
if np.isnan(ds1):
ds1 = 0.0
try:
ds2 = self._get_pixel_distance_along_axis(
interval_expanded[1], +0.5)
except Exception:
cbook._warn_external("Unable to find pixel distance "
"along axis for interval padding of "
"ticks; assuming no interval "
"padding needed.")
ds2 = 0.0
if np.isnan(ds2):
ds2 = 0.0
interval_expanded = (interval_expanded[0] - ds1,
interval_expanded[1] + ds2)
ticks_to_draw = []
After Change
if interval[1] <= interval[0]:
interval = interval[1], interval[0]
inter = self.get_transform().transform(interval)
ticks_to_draw = []
for tick, loc, label in tick_tups:
// draw each tick if it is in interval. Note the transform


- setContentAreaFilled(boolean) - Method in class framework.ColorButton
-
- setHasVoted(boolean) - Method in class framework.Controller
-
has the vote been made
- setHoverBackgroundColor(Color) - Method in class framework.ColorButton
-
- setKept(boolean) - Method in class entity.PolicyCard
-
Resets the card value
- setNewPositions() - Method in class entity.PolicySelection
-
Sets the positions of the new president
- setNextState(boolean) - Method in class entity.Votecard
-
- setPressedBackgroundColor(Color) - Method in class framework.ColorButton
-
- setRoles() - Method in class framework.MainMenu
-
Sets the roles of the players in the file
- setTextArea() - Method in class framework.MainMenu
-
This sets the panel up for the initial part of the game.
- setUserName(String) - Method in class entity.PlayerList
-
Sets the username of the player
- SLCanvas - Class in ui
-
This is our secret leader canvas (hence SL before canvas).
- SLCanvas() - Constructor for class ui.SLCanvas
-
Does the upper level drawing of the game
- SLFrame - Class in ui
-
This is our secret leader frame (hence SL before frame).
- SLFrame() - Constructor for class ui.SLFrame
-
Initializes the games window and initial files
- SLPanel - Class in ui
-
This is our secret leader panel (hence SL before panel).
- SLPanel() - Constructor for class ui.SLPanel
-
Runs the logic of the stage of the game
- SLPanel.GameState - Enum in ui
-
States**
JOINING: The starting portion of the game
PLAYING: ???
VOTING: When the people are voting for the chancellor
WAITING: When the game needs to sit at a rest for a period of time
POLICY: When the president and chancellor are selecting the policies
SELCTION: The stage where the President is selecting a chancellor
BLUEGAMEOVER: When the blue team has won the game
REDGAMEOVER: When the red team has won the game
- SLTest - Class in JUnitTesting
-
- SLTest() - Constructor for class JUnitTesting.SLTest
-


|
Convex Hull
|
#include "convex_hull_structs.h"
Functions | |
| PolarPoint | convertToPolar (Point p, Point origin) |
| Point | converttoCartesian (PolarPoint p, Point origin) |
| int | compareTheta (PolarPoint p, PolarPoint q) |
| int | isEmpty (Node *root) |
| void | push (Point p, Node **root) |
| Point | pop (Node **root) |
| Point | peek (Node **root) |
| void | printStack (Node **root) |
| void | printArray (PolarPoint p[], int n) |
| void | printArray (Point p[], int n) |
| void | swap (int i, int j, PolarPoint inp[]) |
| void | swap (int i, int j, Point inp[]) |
| int compareTheta | ( | PolarPoint | p, |
| PolarPoint | q | ||
| ) |
Compares two PolarPoints based on which has lower theta
| p | PolarPoint 1 |
| q | PolarPoint 2 |
| Point converttoCartesian | ( | PolarPoint | p, |
| Point | origin | ||
| ) |
Converts into cartesian and then shifts origin
| p | PolarPoint to be converted |
| origin | Origin in cartesian |
| PolarPoint convertToPolar | ( | Point | p, |
| Point | origin | ||
| ) |
Shifts the origin and then converts to Polar format
| p | Point in cartesian that needs to be converted |
| origin | Point in cartesian that is treated as origin |
| int isEmpty | ( | Node * | root | ) |
| void printArray | ( | PolarPoint | p[], |
| int | n | ||
| ) |
Prints out all the elements in the array passed
| p | Array to be printed |
| n | Length of the array |
| void printArray | ( | Point | p[], |
| int | n | ||
| ) |
Prints out all the elements in the array passed
| p | Array to be printed |
| n | Length of the array |
| void printStack | ( | Node ** | root | ) |
| void swap | ( | int | i, |
| int | j, | ||
| PolarPoint | inp[] | ||
| ) |
Swaps the elements i and j in the inp array passed
| i | integer index |
| j | integer index |
| inp | PolarPoint array |


L
D
^_^
Assignment 1
Assignment 2
Assignment 3
Assignment 4
Assignment 5
Assignment 6
Home
Assignments
Assignment 1
Assignment 2
Assignment 3
Assignment 4
Assignment 5
Assignment 6
Web Links
Sheridan Home Page
Class Plan
Pictures
Journal
About
Resume
Sign Up
Login
Login to Your Account
Register
-
Forgot Password
My Resume
alt :
Mena Shafik 2016.pdf
Future Company


Learn more about who we are.

General information
The Engineering Science Student Society is established to serve and represent the interests of its members to the School of Engineering Science, throughout Simon Fraser University, and beyond to industry and other engineering societies. If your declared major/minor is in engineering, or you’re taking any engineering science course, then you are automatically a member of the ESSS.
The ESSS, run entirely by students like yourself, promotes school spirit and fosters community building by providing opportunities for you to interact with fellow students, faculty, staff and industry. Social events take place throughout the year, and the Student Society also organizes career fairs and sends members to conferences including the Western Engineering Competition and the Canadian Engineering Competition. The Student Society also has cheap pop and snacks in the undergraduate lounge, and sells branded merchandise for you to show off your engineering pride.
Memberships
The SFU Engineering Science Student Society is part of the following larger organizations. They hold many events year round that SFU Engineering Students are therefore eligible to attend. These events include conferences, professional development sessions, and engineering competitions. Consult their individual webpages or your e-mail inbox (as events are announced) for more information.
As per Article 1.1 of the Engineering Science Student Society (ESSS) Constitution, automatic membership in the ESSS shall be extended to all students within the School of Engineering Science at Simon Fraser University and shall include:
- Current SFU students who in one of the previous three consecutive semesters were:
- Declared majors
- Declared minors
- Any current SFU student that is enrolled in any course offered by the School of Engineering Science.
You are automatically a member if you fall into one of these groups of students.
Executives
Michael Fujiwara
President
president[AT]esss[DOT]ca
Shahira A. Azhar
VP Academic
academic[AT]esss[DOT]ca
Vivian Pan
VP External
external[AT]esss[DOT]ca
Gordon Ho
VP Finance
finance[AT]esss[DOT]ca
Fabio Bollinger
VP Administration
admin[AT]esss[DOT]ca
Reem Mustafa
VP Social
social[AT]esss[DOT]ca
Shayne Kelly II
SFSS Council Representative
council-rep[AT]esss[DOT]ca
Directors
Connor Floyd
Common Room Director
Raunaq Singh
Diversity Director
Jasman Batra
Merchandise Director
Edward Leung
opFair Director
Mason Duan
Publications Director
Jacob Cheng
Spirit Director
Eric Ling
Sponsorship Director
Office and common room
Our common room and office are located on the 10000 level of the Applied Science Building. Our executives can be found during their office hours in ASB 10868.
Here’s a map to get you through it.


WITNESS LIST
Corrections Committee
April 22, 2014 - 2:00 PM
Interim Charge #3 - Private-public partnerships within juvenile system
On:
Brooke, Linda (Texas Juvenile Justice Department)
Cohen, Derek (Texas Public Policy Foundation)
Corson, Michelle (Champion)
Lee Carter, Erica (Nurse-Family Partnership)
McClure, Madeline (TexProtects, The Texas association for the Protection of Children)
Registering, but not testifying:
On:
Meyer, Michael (Texas Juvenile Justice Department)
1


"SPARQLWrapper" (information can be found here) is one convenient resource for integrating SPARQL queries into your project. Simply install the SPARQLWrapper package with
pip install SPARQLWrapper
and you are on your way! This package allows you to make SPARQL queries (and thus query DBpedia) from Python without any further hassle! An example is shown below, using a query from earlier in the tutorial:
If you are copying this example, you will have to change the "album" or "title" to whatever your variables are in your SPARQL query. When this code is run, you will get an output with each line containing the album and title of the result, like
http://dbpedia.org/resource/Warning_(Green_Day_album) http://dbpedia.org/resource/Warning_(Green_Day_song)
http://dbpedia.org/resource/21st_Century_Breakdown http://dbpedia.org/resource/East_Jesus_Nowhere
http://dbpedia.org/resource/Awesome_as_Fuck http://dbpedia.org/resource/East_Jesus_Nowhere
These results are returned as links, which are resources in dbpedia, referring to the objects / properties.
This is just one way to integrate these queries into your project, but hopefully it's a good foothold to get started!
Use RelFIinder to discover internal relationship between objects. The RelFinder is based on the open source framework Adobe Flex, easy-to-use and works with any RDF dataset that provides standardized SPARQL access.
Use it for knowledge, for research paper, for projects, and for your own interest.
For example, if we want to know the relationship between Valadmir Putin and Donald Trump, we can directly pu
Option:
<xml version="1.0" encoding="utf-8" >
<data>
<proxy>
<url>http://www.visualdataweb.org/relfinder/proxy.php</url>
</proxy>
<endpoints>
<endpoint>>
>name>DBpedia</name>
<abbreviation>dbp</abbreviation>
<descriptionLinked>Data version of Wikipedia.</description>
<endpointURI>http://dbpedia.org</endpointURI>
<dontAppendSPARQL>true</dontAppendSPARQL>
<defaultGraphURI>http://dbpedia.org</defaultGraphURI>
<isVirtuoso>true</isVirtuoso>
<useProxy>false</useProxy>
<method>POST</method>
<autocompleteURIs>
<autocompleteURI>http://www.w3.org/2000/01/rdf-schema#label</autocompleteURI>
...
</autocompleteURIs>
<autocompleteLanguage>en</autocompleteLanguage>
<ignoredProperties>
<ignoredProperty>http://www.w3.org/1999/02/22-rdf-syntax-ns#type</ignoredProperty>
...
</ignoredProperties>
<abstractURIs>
<abstractURI>http://dbpedia.org/property/abstract</abstractURI>
...
</abstractURIs>
<imageURIs>
<imageURI>http://dbpedia.org/ontology/thumbnail</imageURI>
...
</imageURIs>
<linkURIs>
<linkURI>http://purl.org/ontology/mo/wikipedia</linkURI>
...
</linkURIs>
<maxRelationLength>2</maxRelationLength>
</endpoint>
<endpoint>
...
</endpoint>
</endpoints>
Downloads all those files from this open source
Note: Make sure that you use the same folder structure and file names (incl. capital and small letters) and that you set the access rights properly. If you start your server now and enter the URL of the RelFinder.swf in your Web browser (e.g. http://localhost/relfinder/RelFinder.swf), it should access the DBpedia dataset by default. You can then edit the Config.xml so that it works with your dataset(s).
Then, it will work, and go to discover the relevance between everything in the universe.
Why DBPedia is a revoluntionized technology?
How does DBPedia reflect decentralization?
https://web.archive.org/web/20100202094110/http://www.wiwiss.fu-berlin.de/en/institute/pwo/bizer/research/publications/Bizer-etal-DBpedia-CrystallizationPoint-JWS-Preprint.pdf
http://www.visualdataweb.org/integrating.php


| < Day Day Up > |
How to Contact UsWe have tested and verified the information in this book to the best of our ability, but you may find that features have changed (or even that we have made mistakes!). Please let us know about any errors you find, as well as your suggestions for future editions, by writing to:
To ask technical questions or comment on the book, send email to: We have a web site for the book, where we'll list examples, errata, and any plans for future editions. You can access this page at: http://www.oreilly.com/catalog/gnu3/ When you see a Safari® enabled icon on the cover of your favorite technology book that means the book is available online through the O'Reilly Network Safari Bookshelf. Safari offers a solution that's better than e-Books. It's a virtual library that let's you easily search thousands of top tech books, cut and paste code samples, download chapters, and find quick answers when you nee the most accurate, current information. Try it free at http://safari.oreilly.com. For more information about this book and others, see the O'Reilly web site: You can also send questions about Emacs and suggestions about this book to<EMAIL_ADDRESS>|
| < Day Day Up > |


Overview
I worked with a team of five mechanical engineers to develop a prototype for an IoT cooking experience integrating sensors and existing devices. This was a class project for ME110, New Product Development. The prompt from our sponsors, Samsung, was “Leisure and Entertainment,” ideally something using speakers and sensors.
Involvement
- Contributed to all aspects of product development process
- Created interactive prototypes in Marvel and Invision
- Prepared decks and led presentations
Tools
Pencil and paper, whiteboard, post-its, Marvel, Invision, Adobe Illustrator
Process
Concept Generation
We were given a broad prompt “make an IoT product within the theme of Leisure and Entertainment” and told we could do pretty much what we wanted. As a result, we revisited the brainstorm stage many times and conducted several rounds of interviews as we slowly narrowed our focus to enhancing the cooking experience.
I learned a lot by visiting people in person and asking them to show me how they did things. For example, one of my interviewees said he enjoyed listening to music and talkshows while cooking, but didn’t bring up anything inconvenient about the process. When I asked to see how he set up his cooking space, however, he grabbed his laptop and placed it on top of the trashcan! It had become such a regular thing for him that he didn’t think to bring it up when I asked at first.
The user needs we concluded from our interviews:
- control devices without getting them dirty or breaking workflow
- adapt to changing environment with little user involvement (sounds, placement in the kitchen)
- improve cooking skills
- share accomplishments with friends family
- figure out what to cook
Prototypes
We created three different prototypes for our midterm tradeshow. They each tested a different aspect of our cooking ideas.
- Mr. Pan: interactive cooking pan. We hooked up a pan to an Arduino, and programmed it to play relevant music when someone started “cooking” inside of it
- Smart Cutting Board: displayed videos and recipes. We displayed mockups on an iPad and had people interact with it using plastic utensils.
- Basket: a cooking challenge app. We tested the concept with a low-fi interactive prototype made in Marvel.
I was in charge of creating the Basket prototype. I chose to use Marvel as my prototyping tool because I could take pictures of my sketched mockups and turn those directly into my prototype. I didn’t want to create something in Illustrator or Photoshop so early on, because that would keep people from giving feedback on the concept itself.
We distributed surveys to everyone who tried our products, asking when and how often they would think about using the product, as well as what their experience with the prototype was like. We also asked which of the products they enjoyed the most out of the three. We collected approximately 30 surveys total. The responses confirmed most of the conclusions from our user interviews, and brought a few new insights.
- Users wanted notifications and alerts during the cooking process.
- They didn’t want to buy an entirely new device or kitchen appliance - they would prefer if the product were sold separately and could integrate with their existing products
- They liked having recipe suggestions.
- They wanted to be able to control their music while cooking.
Concept Selection
Post-tradeshow, we evaluated the three prototypes against what we learned from the survey feedback. Mr. Pan and the Smart Cutting Board both were well-received at the tradeshow. People liked the learning aspect, as well as the integrated nature of the controls. One problem they had with both devices, however, was that they would have to buy a completely new appliance in order to get these features.
When we conducted competitive analysis, we also found a Mr. Pan-like product on Kickstartr already — an intelligent pan that used temperature information to help users cook more accurately. There were also a variety of recipe and cooking apps for smartphones and tablets out in the market already. To figure out how to find a competitive advantage in this market, we made a concept matrix and decided to create a completely new product, taking relevant ideas from each prototype.
The key change from our previous prototypes was a shift from an intelligent cooking device, to sensors that could be attached to existing appliances. To lock down finer details of our new prototype, we conducted about 30 more short interviews to find the most needed features.
Final Prototype
Zest is a collection of sensors that can be attached to various cooking implements and cookware. When they sync with the mobile application, they can provide contextual cooking instructions and notifications. The sensors also act as volume control, so no matter where you are in your kitchen you can adjust your entertainment as you wish.
We designed Zest with the above roadmap in mind. I spoke with many people who didn’t cook regularly, or wanted to but weren’t able to for one reason or another. For some people, it was really about avoiding doing dishes; for others, the “ominvore’s dilemma” struck them every time they opened the fridge to try and figure out what to cook. Some people simply didn’t want to touch raw food or go through the effort of preparing it when take-out was readily available.
We wanted to make a product that could support people at every stage of the cooking process, transitioning them from finding it a chore, to becoming eager to learn more, to getting creative and sharing their success.
I was in charge of creating the mobile app portion of the prototype. It was challenging to work out the recipe screens, and they could have done with more user testing if we had the time. Zest provided not only cooking instructions, but music control as well — this meant parceling out screen estate accordingly and deciding what to show and what to hide away.
This time I used Invision to string together the views, since we wanted something more polished to test out at the final showcase. Invision can only handle one orientation at a time, though, so the prototype is split into two parts for easier desktop viewing.
Onboarding Cooking Instructions
Since we changed product ideas near the end of the semester, we didn’t get to test Zest out with that many users. If we had more time, I would have wanted to do some actual kitchen testing with this prototype. Would they be comfortable with these sensors stuck all over their appliances? Do the steps and the cooking timers make sense? An important consideration our mentors told us to think about was repeatability. Would sensor set-up be troublesome enough that users would decide not to integrate it into their usual workflow?
Final Thoughts
An important lesson learned from this project was how to factor in design within a business context. How can you design something that can win market share from other products, or generate a primary market, like Apple once did with the iPhone? Coming up with something that meets user needs is a first step, but other considerations come into play — available technology, profitability, manufacturability, sustainability and so on. A product can only survive if it manages to balance everything; no wonder iteration is so often a fitting development method.
Another big part of this experience was working within a multi-disciplinary team. It was great to see different perspectives from my teammates, who were mechanical engineers, with one also pursuing architecture and one doubling with EECS. If I had been on a team of only CS students, I think we would have mostly explored software-only solutions. With more variety in thinkers at the table, we managed to explore many more possibilities!


Repository of data coming from the MERIS spectrometer on board of the ENVISAT satellite has been created on the COMETA infrastructure with the gLibrary platform (https://glibrary.ct.infn.it).
This repository contains a subset of the MERIS Level3 demonstration products. More information on the dataset can be found here: http://earth.eo.esa.int/level3/meris-level3
gLibrary is a INFN platform to create and manage digital repository on e-infrastructure, providing easy-to-use front-ends and APIs that hides the underlying infrastrcture services.
The app implements a gLibrary client able to browse the repository and to download various kinds of digital assets and in various format (JPG and TIFF images, XML, HDF, NC data files) . The user can navigate the repository using a hierarchical filter mechanism based on asset metadata (product type, period, date) that allows to find easily the asset he is interested in. He can finally inspect the complete set of their metadata and proceed to the download from the infrastructure servers, finally viewing them on the device screen.


Reader
My Library
Recent Books
{{book.title}}
{{book.author}}
(Book Title)
Cut
Copy
Paste
Chapters
Bookmarks
Annotations
Chapters
Bookmarks
Annotations
Paste
Cut
Copy
Paste
(Put column/page view here and render as card.)


---
layout: post
title: count vs size on ActiveRecord select queries
date: '2015-11-23T21:09:00.001-08:00'
author: Mark J. Lehman
tags:
- rails
- ruby
- debugging
- activerecord
modified_time: '2015-12-26T21:21:23.565-08:00'
blogger_id: tag:blogger.com,1999:blog-4459370175540830177.post-241288833602905613
blogger_orig_url: http://spaghettirefactory.blogspot.com/2015/11/count-vs-size-on-activerecord-select.html
---
I stumbled on this bit of weirdness when using the SQL query User.select(:id, :name, :email).count
. It threw a PG::UndefinedFunction
error. Using User.select(:id, :name, :email).size
worked instead.
Out of curiosity, I did some digging. According the the ActiveRecord docs,
not all valid select expressions are valid count expressions. TheI also stumbled on an issue on rails Github issues page about this, and a very helpful comment from rafaelfranca explained that I can also use
specifics differ between databases. In invalid cases, an error from
the database is thrown.
count(:all)
.


--- layout: post title: cfqueryparam tags: [] status: publish type: post published: true meta: {} ---
As part of our dev guidelines for CFMX, all data that is submitted by a user to the database is passed in by making use of the <cfqueryparam> tag, which basically allows you to validate the data type of the value submitted. There also a few additional parameters that allow you to further validate the values passed such as length, scale, whether it can be null or not, or if it is a list. It's a useful addition to protecting your applications. However there appears to be a bug with single quotes in CFMX when you are inserting data, i.e. single quotes are escaped and passed into the database, e.g. O'Brien becomes O''Brien. The documentation for CFMX specifically states that:
"New in ColdFusion MX: ColdFusion automatically escapes simple-variable, array-variable, and structure-variable references within a cfQuery tag body or block. (Earlier releases did not automatically escape array-variable references.)"
However out of the box it doesn't, admittedly I have only come across this problem in conjunction with components and haven't tested it outside of these. Now this has since been patched, but for those not in a position to apply it, there is a workaround. Simply wrap the string in the PreserveSingleQuotes() function. As a result your SQL statement should look something like this:
?
YourField = <cfqueryparam value="#trim(PreserveSingleQuotes(YourField))#" cfsqltype="CF_SQL_VARCHAR">,
?


The \co-op directory on your largest drive contains the databases for all your project (that's the default during setup). Back up this folder and its contents. You might also want to back-up your project files, even though it is not strictly necessary.
If you don't want to back up your project files, make sure that your history is in good order--try selecting the earliest script and do Selection > Export Version. If it fails, some of the files in your history might not be recoverable and you won't be able to restore them based purely on history.
After you reinstall Code Co-op, copy the folders contained in the back-up \co-op folder to the new \co-op folder on your machine. Restore project files from the same backup using exactly the same paths as the original. To be on the safe side, launch Code Co-op and run Project > Repair for each project.
If you haven't backed up project files, Project > Repair will restore them using your project's history (this is why you have to be positive that your history is not corrupt). If your project is large, this may take a bit of time.


Stoneskin
Makes your skin as hard as stone, diminishing the effectiveness of all piercing attacks used on you.
${value}% Bleeding Resistance
5 8 12 15 18 21 25 28 31 34 38 41
${value}% Pierce Resistance
5 8 12 15 18 21 25 28 31 34 38 41
MaxLevel
8
UltimateLevel
12


File Catalog.lua
Functions
| Catalog:addOriginalFilename (photo, fn) | Add photo's original filename to lookup table. |
| Catalog:assureMetadataColumnInViewFilter (metadataId, pluginId) | Assure specified metadata column is active in current view filter. |
| Catalog:assurePhotoIsSelected (photo, photoPath) | Make specified photo the *only* photo selected, whether source is active or not. |
| Catalog:assurePluginCollection (name, tries, pluginName) | Assures collection is created in plugin set. |
| Catalog:assurePluginCollectionSet (tries) | Assures collection set is created for plugin. |
| Catalog:assurePluginCollections (names, tries, doNotRemoveDevSuffixFromPluginName, pluginName) | Assures collections are created in plugin set. |
| Catalog:batchGetLockMetadata (photos, call) | Get batch (ChangeManager) lock-status metadata. |
| Catalog:clearViewFilter (noYield) | Clears view filter so all photos will be showing. |
| Catalog:createCollection (name, parent, returnExisting) | Case insensitve version of like-named lr-catalog method. |
| Catalog:createCollectionSet (name, parent, returnExisting) | Case insensitve version of like-named lr-catalog method. |
| Catalog:createSmartCollection (name, smarts, parent, returnExisting) | Case insensitve version of like-named lr-catalog method. |
| Catalog:createVirtualCopies (params) | Create multiple virtual copies. |
| Catalog:createVirtualCopy (photo, prompt) | Creates a virtual copy of one photo. |
| Catalog:deletePhotos (params) | Delete photos. |
| Catalog:findPhotoByPath (file, copyName, rawMeta, fmtMeta) | Similar in purpose to lr-catalog method of same name, except takes virtual copy status into consideration. |
| Catalog:getAnyPhoto (notMissing, typeKey, call) | Get a photo, any photo (nil means no photo gettable). |
| Catalog:getBatchFormattedMetadata (photos, ...) | Get batch of formatted metadata without bringing down the system. |
| Catalog:getBatchRawMetadata (photos, ...) | Get batch of raw metadata without bringing down the system. |
| Catalog:getCatDir () | Get directory containing catalog (just a tiny convenience/reminder function). |
| Catalog:getCollection (name, parent) | Get collection *or* smart collection of specified name in specified parent, if it exists. |
| Catalog:getCollectionSetPhotos (collSet) | Get collection set photos (in regular collections only). |
| Catalog:getCollectionSetPopupItems (pub) | Get collection set popup items. |
| Catalog:getExtSupport (ext) | Get support type for all or specified extension. |
| Catalog:getFilmstripPhotos (assumeSubfoldersToo, ignoreIfBuried, excludeSource) | Get list of photos in filmstrip *** DEPRECATED in favor of getVisiblePhotos, which could stand to be augmented with parameters like includeIfBuried... |
| Catalog:getFolder (photo, photoPath) | Get lr folder for photo, if possible. |
| Catalog:getFolderByPath (folderPath) | Equivalent to Lr's native method, except works for unmapped network drives too (Lr's doesn't, as of Lr5.4 anyway). |
| Catalog:getFolderSet (photos, cache) | Get set of folders housing specified photos. |
| Catalog:getFormattedMetadata (photo, name, fmtMeta) | Get formatted metadata, preferrable from that read in batch mode, else from photo directly. |
| Catalog:getLocalImageId (photo) | Get local image id for photo. |
| Catalog:getOriginalFilename (photo) | Get original filename corresponding to photo. |
| Catalog:getPhotoName (photo, fullPath, rawMeta, fmtMeta) | Get photo name or path which includes copy name when appropriate. |
| Catalog:getPhotoNameDisp (photo, fullPath, metaCache) | Get photo name or path which includes copy name when appropriate. |
| Catalog:getPhotoSetFromSeedPhotos (seedPhotos, cache) | Get photo set from seed photos. |
| Catalog:getPluginCollection (collName) | Determine if plugin collection exists, and get it. |
| Catalog:getPropertyForPlugin (name) | Get catalog metadata property. |
| Catalog:getPublishService (id) | Get publish service, and name, corresponding to specified ID. |
| Catalog:getPublishServicePopupItems () | Get publish service popup items. |
| Catalog:getRawMetadata (photo, name, rawMeta) | Get raw metadata, preferrable from that read in batch mode, else from photo directly. |
| Catalog:getSelectedPhotos (photo) | Get selected photos. |
| Catalog:getSmartCollection (id) | Get smart collection, and name. |
| Catalog:getSmartCollectionPopupItems (startHere) | Get smart collection popup items (within catalog or publish service). |
| Catalog:getSmartColls (photo, collSet) | Get smart collections associated with specified photo ###1 coll-set? |
| Catalog:getSourceName (source) | Get source name, and id if special. |
| Catalog:getSourcePhotos (assumeSubfoldersToo, ignoreIfBuried, metaIds) | Get list complete list of photos in selected sources, unless buried in stack (optional). |
| Catalog:getSourceType (source) | get source type, regardless of source. |
| Catalog:getStackRelation (photo1, photo2, cache) | Get stack relationship |
| Catalog:getTargetPhotos (p) | Get target photos. |
| Catalog:getVisiblePhotos (params) | Get photos visible in filmstrip (as filtered, as stacked, ... |
| Catalog:initFolderCache (unInit) | Initialize folder cache to assure fresh results via (and set mode of) get-folder-by-path. |
| Catalog:initForOriginalFilenames () | Determine if original filenames are even a possibility, and if so, prepare.. |
| Catalog:initSmartColls () | Initialize caches/lookups to be used by get-smart-colls. |
| Catalog:isBuriedInStack (photo, bm) | Determine if specified photo is buried in collapsed stack in folder of origin. |
| Catalog:isLocked (photo, orXmp, cache) | Determine if locked, and if so: return lock-date as string, as 2nd item in return list (1st item is boolean locked, or not). |
| Catalog:isMetadataColumnActive (metaIds, filter) | Determine if specified metadata columns are active in specified lib view filter. |
| Catalog:isMissing (photo, cache) | Determine if photo is missing - i.e. |
| Catalog:isOriginalFilenamesInit () | Determine if original filename subsystem is properly initialized. |
| Catalog:isSmartPreview (photo, cache) | Determine if photo has a smart preview. |
| Catalog:new (t) | Constructor for new instance. |
| Catalog:newClass (t) | Constructor for extending class. |
| Catalog:readPhotoMetadata (photo, photoPath, alreadyInLibraryModule, service, manualSubtitle) | Read metadata for one photo. |
| Catalog:refreshDisplay (photo, photoPath) | Refresh display of recently changed photo (externally changed). |
| Catalog:restoreSelPhotos (selPhotos) | Restore previously saved photo selection and related settings. |
| Catalog:saveMetadata (photos, preSelect, restoreSelect, alreadyInGridMode, service) | Save metadata for (multiple) specified photos. |
| Catalog:savePhotoMetadata (photo, photoPath, targ, call, noVal, oldWay) | Save metadata for one photo. |
| Catalog:saveSelPhotos () | Save selected photos, and related info/settings, for restoral later. |
| Catalog:selectOnePhoto (photo) | select one photo, de-select all others - confirm selection. |
| Catalog:selectPhoto (photo) | Make specified photo most selected, without changing other selections if possible. |
| Catalog:selectPhotos (photo, photos, assureFolders, metaCache) | Set selected photos, and verify selection, with option to select folders if necessary to assure photos will be selected, even if not in filmstrip. |
| Catalog:setActiveSources (sources) | Set active sources, and verify all were properly set. |
| Catalog:setCollectionPhotos (coll, photos, tmo) | Set collection photos. |
| Catalog:setPropertyForPlugin (name, value, validate) | Set catalog metadata property if not already. |
| Catalog:update (tmo, name, func, ...) | Wrapper for named/undoable catalog:withWriteAccessDo method - divide to conquor func. |
| Catalog:updatePrivate (tmo, func, ...) | Wrapper for un-named catalog:withPrivateWriteAccessDo method - divide to conquor func. |
| Catalog:withDo (tryCount, func, catalog, p1, p2, ...) | Catalog access wrapper that distinquishes catalog contention errors from target function errors. |
| Catalog:withRetries (tryCount, func, p1, p2, ...) | Catalog access wrapper that distinquishes catalog contention errors from target function errors. |
Functions
- Catalog:addOriginalFilename (photo, fn)
-
Add photo's original filename to lookup table.
Parameters:
-
photo
: (lr-photo, required) photo -
fn
: (string, required) filename (includes extension, but excludes path).
Usage:
for importer support after new file added to catalog - supports dup. checking.
Return values:
- status (boolean) true iff added.
- message (string) accompanies non-true status to explain.
-
- Catalog:assureMetadataColumnInViewFilter (metadataId, pluginId)
-
Assure specified metadata column is active in current view filter.
Parameters:
-
metadataId
: metadata ID. -
pluginId
: toolkit ID.
Usage:
returns nothing
-
- Catalog:assurePhotoIsSelected (photo, photoPath)
-
Make specified photo the *only* photo selected, whether source is active or not.
Parameters:
-
photo
: (lr-photo, generally required) will be obtained from photo-path if it is passed. -
photoPath
: (string, optional) will be obtained from photo metadata if not passed.
Usage:
present implementation satisfies by adding folder to source, if necessary.
Return value:
- status, but NOT error message - logs stuff as it goes...
-
- Catalog:assurePluginCollection (name, tries, pluginName)
-
Assures collection is created in plugin set.
Parameters:
-
name
: (string, required) the collection name. -
tries
: (number, optional) cat access tmo. -
pluginName
: (string, optional) defaults to app--get-plugin-name()
Usage:
Must NOT be called from a with-write-access-gate.
Return value:
- collection or throws error trying.
-
- Catalog:assurePluginCollectionSet (tries)
-
Assures collection set is created for plugin.
Parameters:
-
tries
: (number, optional) cat access tmo.
Usage:
Must NOT be called from a with-write-access-gate.
Return value:
- collection or throws error trying.
-
- Catalog:assurePluginCollections (names, tries, doNotRemoveDevSuffixFromPluginName, pluginName)
-
Assures collections are created in plugin set.
Parameters:
-
names
: (variable, required) if array of strings, then sub-collection names to be created in plugin collection set.
if 'string', then name of single plugin collection.
if array of structures, then elements are: 'name', and 'searchDesc' - intended for defining smart collection(s). -
tries
: (number, default = 20) maximum number of catalog access attempts before giving up. -
doNotRemoveDevSuffixFromPluginName
: (boolean, default = false) pass 'true' if you want to keep the ' (Dev)' suffix in the development version of the collection set. -
pluginName
:
Usage:
NOT be called from a with-write-access-gate.
Return value:
- collections or throws error trying.
-
- Catalog:batchGetLockMetadata (photos, call)
-
Get batch (ChangeManager) lock-status metadata.
Parameters:
-
photos
: -
call
:
Return values:
- lock-data lookup table: keys are photos, values are tables with single boolean member: 'locked' (I must have had lock-date in mind in the beginning..).
- num-locked number of locked photos.
-
- Catalog:clearViewFilter (noYield)
-
Clears view filter so all photos will be showing.
Parameters:
-
noYield
: (boolean, default false) if true, will return immediately, but be forewarned: this function probably needs some "settling" time.
if false, this method may yield or sleep as this method deems appropriate.
Usage:
Dunno how to control global lock who-de-kai.
-
- Catalog:createCollection (name, parent, returnExisting)
-
Case insensitve version of like-named lr-catalog method.
Parameters:
-
name
: -
parent
: -
returnExisting
:
-
- Catalog:createCollectionSet (name, parent, returnExisting)
-
Case insensitve version of like-named lr-catalog method.
Parameters:
-
name
: -
parent
: -
returnExisting
:
-
- Catalog:createSmartCollection (name, smarts, parent, returnExisting)
-
Case insensitve version of like-named lr-catalog method.
Parameters:
-
name
: -
smarts
: -
parent
: -
returnExisting
:
-
- Catalog:createVirtualCopies (params)
-
Create multiple virtual copies.
Parameters:
-
params
: (table) elements:
photos (array, default = selectedPhotos) of LrPhoto's.
copyName (string, default = "Virtual Copy" if Lr5, else "Copy N").
call (Call, required) call with context.
assumeGridView (boolean, default = false )
cache (LrMetadataCache, default = nil ) cache for base photo metadata.
verify (boolean, default = true ) set false to subvert copy verification.
Return values:
- copies (array of LrPhoto) iff success.
- errMsg (string) non-empty iff unsuccessful.
-
- Catalog:createVirtualCopy (photo, prompt)
-
Creates a virtual copy of one photo.
Parameters:
-
photo
: (LrPhoto, default nil) Photo object to create virtual copy of, or nil to create copy of most selected photo. -
prompt
: (boolean, default false) Pass true to prompt user about this stuff, or false to let 'er rip and take yer chances (definitive status will be returned).
Usage:
Note: this is used to create a single virtual copy in both Lr4 and Lr5 implementations. Multiple virtual copies can be created using the new Lr5 method.
In Lr4, virtual copy creation itself uses scripting; in Lr5 (and Lr4) switching to grid mode requires scripting (for smooth operation anyway) I did build
in some logic for manual user intervention/assurance, but it's testing has gotten less over the years.Must be called from asynchronous task.
No errors are thrown - check return values for status, and error message if applicable.
Can be used to create multiple copies, by calling in a loop - but is very inefficient for doing multiples like that.
if you want multiples, you should code a new method that selects all photos you want copied, then issues the Ctrl/Cmd-'
And for robustness, the routine should check for existence of all copies before returning with thumbs up.Its up to calling context to assure Lightroom is in library or develop modules before calling.
Hint: calling context can restore selected photos upon return, or whatever...
Return values:
- photo-copy (lr-photo) if virtual copy successfully created.
- error-message (string) if unable to create virtual copy, nil if user canceled.
-
- Catalog:deletePhotos (params)
-
Delete photos.
Parameters:
-
params
: table of parameters
call (Call, required) call or service... photos (array, required) photos to delete promptTidbit (string, default="Items") e.g. "Snapshot photos" final (boolean, default=false) only applies if mac atm: means dialog box is to be the final box of the service.
Usage:
*** ASSURE LIST OF FILES TO DELETE HAS ALREADY BEEN LOGGED, OTHERWISE THIS METHOD WILL MAKE A LIAR OUT OF THE CALLING CONTEXT.
call to delete photos.
depends on prefs: 'preservePicks', 'delayForManualMetadataSaveBox' (used for manual delete box).
as of 30/May/2014, will always prompt user before deleting - user can then choose manual or let plugin splatt delete them.
Return value:
- status (boolean) true iff photos were deleted; false => not. Note: no qualifying message (check call to see if canceled).
-
- Catalog:findPhotoByPath (file, copyName, rawMeta, fmtMeta)
-
Similar in purpose to lr-catalog method of same name, except takes virtual copy status into consideration.
Parameters:
-
file
: path -
copyName
: virtual copy name, if not wanting master photo. -
rawMeta
: batch of.. -
fmtMeta
: batch of..
Usage:
And one day it will not be case sensitive.
Hopefully to be replaced by a version which uses metadata cache instead of raw/fmt-meta params.
-
- Catalog:getAnyPhoto (notMissing, typeKey, call)
-
Get a photo, any photo (nil means no photo gettable).
Parameters:
-
notMissing
: set true to assure said photo is not offline (in case sample op is to extract preview, or exiftool it..). -
typeKey
: (optional) 'raw', 'rgb', 'video'. -
call
: (optional) for setting caption (in case op may take a while.
Usage:
for sample ops..
-
- Catalog:getBatchFormattedMetadata (photos, ...)
-
Get batch of formatted metadata without bringing down the system.
Parameters:
-
photos
: -
...
:
Usage:
I'm not sure about the value of this function - I think this did not fix a problem caused by something else.
Gets in batches of 1000 instead of all at once, presumably to keep Lr from being unresponsive or using too much memory or something - don't remember 'zactly.
must be called from async task.
this method may take a loooong time to run, so consider displaying porgress scope before calling.
Return value:
- table, indexed by photos, values are metadata tables, whose keys are metadata ids and values are metadata.
-
- Catalog:getBatchRawMetadata (photos, ...)
-
Get batch of raw metadata without bringing down the system.
Parameters:
-
photos
: array of lr-photos -
...
: raw IDs
Usage:
I'm not sure about the value of this function - I think this did not fix a problem caused by something else.
Gets in batches of 1000 instead of all at once, presumably to keep Lr from being unresponsive or using too much memory or something - don't remember 'zactly.
must be called from async task.
this method may take a loooong time to run, so consider displaying progress scope before calling.
Return value:
- table, indexed by photos, values are metadata tables, whose keys are metadata ids and values are metadata.

- Catalog:getCollection (name, parent)
-
Get collection *or* smart collection of specified name in specified parent, if it exists.
Parameters:
-
name
: -
parent
:
-
- Catalog:getCollectionSetPhotos (collSet)
-
Get collection set photos (in regular collections only).
Parameters:
-
collSet
: collection set object.
Usage:
uses breadth-first algorithm.
Return value:
- photos (array) may be empty, never nil.
-
- Catalog:getCollectionSetPopupItems (pub)
-
Get collection set popup items.
Parameters:
-
pub
: (boolean, default=false) set true for publish services collection sets; false => catalog coll sets.
Return values:
- items for popup: titles are collection set paths.., values are local IDs or "LrCatalog".
- lookup keys are item values, values are item titles.
-
- Catalog:getExtSupport (ext)
-
Get support type for all or specified extension.
Parameters:
-
ext
: extension or nil.
Usage:
make a copy of the returned table if plugin is to change support type strings to tables, or add-on...
Return value:
- supportType (string: 'raw', 'rgb', 'video') or nil, if specified extension is not supported by Lightroom.
DNG is considered raw, even though it could be dng-wrapped jpeg, likewise NEF is considered raw even though it could be rgb internally.. -
- Catalog:getFilmstripPhotos (assumeSubfoldersToo, ignoreIfBuried, excludeSource)
-
Get list of photos in filmstrip *** DEPRECATED in favor of getVisiblePhotos, which could stand to be augmented with parameters like includeIfBuried... - exclude source would not fit, and perhaps should be handled as special case in 1 plugin using it: MissingInAction. consider modifying other plugins to use it.
Parameters:
-
assumeSubfoldersToo
: -
ignoreIfBuried
: -
excludeSource
:
Usage:
*** DEPRECATED.
this function *may* not be perfect, and may return photos even if excluded by lib filter or buried in stack.
presently its working perfectly, but I don't trust it, and neither should you!?
*** originally: function Catalog:getFilmstripPhotos( assumeSubfoldersToo, bottomFeedersToo )
Return value:
- array of photos - may be empty, but never nil (should not throw any errors).
-
- Catalog:getFolder (photo, photoPath)
-
Get lr folder for photo, if possible.
Parameters:
-
photo
: (lr-photo, required) photo whose folder is desired. -
photoPath
: (string, optional) if known in calling context, saves a more expensive call to get-raw-metadata in here.
Return value:
- lr-folder, or nil if no can do.
-
- Catalog:getFolderByPath (folderPath)
-
Equivalent to Lr's native method, except works for unmapped network drives too (Lr's doesn't, as of Lr5.4 anyway).
Parameters:
-
folderPath
: (string, required) path of folder for which corresponding lr-folder object is desired.
Usage:
it is recommended but not required to initialize folder cache before calling the first time.
Return value:
- folder (lr-folder object) hopefully never nil (assuming valid folder-path), but best to check in calling context.
-
- Catalog:getFolderSet (photos, cache)
-
Get set of folders housing specified photos.
Parameters:
-
photos
: (array of lr-photo) required. -
cache
: just needs 'path' to be useful.
Usage:
logs warning(s) if folder(s) not found.
Return value:
- set of lr-folders - maybe empty, but never nil.
-
- Catalog:getFormattedMetadata (photo, name, fmtMeta)
-
Get formatted metadata, preferrable from that read in batch mode, else from photo directly.
Parameters:
-
photo
: (lr-photo, required) the photo. -
name
: (string, required) raw metadata item name. -
fmtMeta
: (table, optional) formatted metadata table read using batch mode.
Usage:
*** deprecated - use metadata cache instead.
-
- Catalog:getLocalImageId (photo)
-
Get local image id for photo.
Parameters:
-
photo
: the photo
Return values:
- imageId (string) local database id corresponding to photo, or nil if problem.
- message (string) error message if problem, else nil.
-
- Catalog:getOriginalFilename (photo)
-
Get original filename corresponding to photo.
Parameters:
-
photo
:
Usage:
*** requires original filenames initialized via SQLiteroom, or the like.
- consider checking for corresponding disk file if pertinent (e.g. photo object may be from stale info, and photo and/or file since deleted..).
Return values:
- filename (string) nil if unavailable.
- excuse (string) nil if available, else reason for no filename.
-
- Catalog:getPhotoName (photo, fullPath, rawMeta, fmtMeta)
-
Get photo name or path which includes copy name when appropriate.
Parameters:
-
photo
: (LrPhoto, required) photo -
fullPath
: (boolean, default = false) true for full-path, else filename only as base. -
rawMeta
: (table, optional) batched raw metadata, or metadata cache. -
fmtMeta
: (table, optional) batched fmt metadata, or nil (cache may include formatted metadata).
Usage:
*** deprecated - use get-photo-name-disp instead (I like the simpler name, but I recommend migrating to a metadata caching scheme).
-
- Catalog:getPhotoNameDisp (photo, fullPath, metaCache)
-
Get photo name or path which includes copy name when appropriate.
Parameters:
-
photo
: (LrPhoto, required) photo -
fullPath
: (boolean, default = false) true for full-path, else filename only as base. -
metaCache
: (Cache, optional) Metadata cache.
-
- Catalog:getPhotoSetFromSeedPhotos (seedPhotos, cache)
-
Get photo set from seed photos.
Parameters:
-
seedPhotos
: (table, required) An array of photos, often obtained from some catalog source. -
cache
:
Usage:
To get top photos, and those underneath too...
Not very efficient if there are lots of expanded stacks, and all underneath are already included in seed photos.
Return value:
- photoSet (table, never nil) keys are photos, values are true.
-
- Catalog:getPluginCollection (collName)
-
Determine if plugin collection exists, and get it.
Parameters:
-
collName
: collection name
Return value:
- collection or nil
-
- Catalog:getPropertyForPlugin (name)
-
Get catalog metadata property.
Parameters:
-
name
: (string, required) property name
Usage:
Gets property for plugin tied to catalog.
Present implementation uses Lightroom preferences and never fails.
Return value:
- value (any) or nil.
-
- Catalog:getPublishService (id)
-
Get publish service, and name, corresponding to specified ID.
Parameters:
-
id
: publish service ID.
Return values:
- publish service
- name
- id
-
- Catalog:getPublishServicePopupItems ()
-
Get publish service popup items.
Return values:
- items for popup: titles are publish service names, values are local IDs.
- lookup keys publish service local IDs, values are tables with: pubSrv, name, pid.
- Catalog:getRawMetadata (photo, name, rawMeta)
-
Get raw metadata, preferrable from that read in batch mode, else from photo directly.
Parameters:
-
photo
: (lr-photo, required) the photo. -
name
: (string, required) raw metadata item name. -
rawMeta
: (table, optional) raw metadata table read using batch mode.
Usage:
*** deprecated - use metadata cache instead.
-
- Catalog:getSelectedPhotos (photo)
-
Get selected photos.
Parameters:
-
photo
:
Usage:
Use instead of lr-catalog's get-target-photos method if you don't want the entire filmstrip to be returned when nothing is selected.
Return value:
- empty table if none selected - never returns nil.

Parameters:
-
id
: smart collection ID.
Return values:
- collection if found, else nil.
- name if found, else excuse.
- path if found, else nil.
-
- Catalog:getSmartCollectionPopupItems (startHere)
-
Get smart collection popup items (within catalog or publish service).
Parameters:
-
startHere
: (collection set or publish service, default = catalog)
Return value:
- popup items: titles are indented collection names, values are collections local-IDs.
-
- Catalog:getSmartColls (photo, collSet)
-
Get smart collections associated with specified photo ###1 coll-set?
Parameters:
-
photo
: -
collSet
:
Usage:
probably needs to be called from async task, protected..
Return value:
- array of smart collections.
-
- Catalog:getSourceName (source)
-
Get source name, and id if special.
Parameters:
-
source
: any source
Usage:
some sources don't have get-name function. this method assures a reasonable name, regardless of source type.
Return values:
- sourceName (string) never empty, never nil. source name will be invented if no get-name function, or source ID if special source is not "registered" here.
- sourceId (string) if special source - as registered here, or source object type, or to-string of source..
-
- Catalog:getSourcePhotos (assumeSubfoldersToo, ignoreIfBuried, metaIds)
-
Get list complete list of photos in selected sources, unless buried in stack (optional).
Parameters:
-
assumeSubfoldersToo
: (boolean, default = true ) will get folders in subfolders too. Note: this only matches the user's filmstrip if he/she is also viewing subfolders, thus the term "assume". -
ignoreIfBuried
: (boolean, default = true ) will exclude photos if not top of stack (or unstacked). -
metaIds
: (array of strings, default = nil ) IDs of metadata items in this plugin that if active, means filtered set should be returned (see example plugin: MissingInAction).
Usage:
Beware: this function *may* not be perfect e.g. may not work if sources are special Lr collections, and not sure about how reliable is the assume-subfolders field, nor ignore-if-buried - you have been warned.
deprecated
Return values:
- photos (array of LrPhoto objects) - may be empty, but never nil (should not throw any errors).
- excludeIfFiltered (boolean), not always returned. hmm... ###3
-
- Catalog:getSourceType (source)
-
get source type, regardless of source.
Parameters:
-
source
: any photo/video source, including catalog or special collection.
Return value:
- sourceType (string) same as source--get-type if said method exists, else "lr-catalog" or "special" (never empty, never nil).

Return values:
- which is above, nil if not in same stack.
- stack position of photo1, 0 if not in a stack
- stack position of photo2, ditto.
-
- Catalog:getTargetPhotos (p)
-
Get target photos.
Parameters:
-
p
: (table, optional) handling members:
* noneSel (string, default=nil) 'allPhotos', 'filmstrip', or nil.
* oneSel (string, default=nil) 'filmstrip', or nil.
Usage:
*** deprecated - may be removed in a future version (or, may not be..).
If multiple selected, they are returned. What happens when none or one are selected depends on parameter table:
if handling member is nil, then selected photos returned without change.
Return value:
- may return empty table, but never returns nil.
-
- Catalog:getVisiblePhotos (params)
-
Get photos visible in filmstrip (as filtered, as stacked, ... ).
Parameters:
-
params
: parameter table:
selectedPhoto (LrPhoto, default=nil) catalog:getTargetPhoto() - in case already available in calling context.
selectedPhotos (array of LrPhoto, default=nil) catalog:getTargetPhotos() - ditto.
metadataCache (LrMetadata::Cache, optional) metadata cache (see code below for expected members).
includeIfBuried (boolean, default=false) visible only? or those underneath in collapsed stacks too.
Usage:
without disturbing users's present selection.
*** BEWARE: adds 'Undo Select' item to undo stack, so DO NOT call from background task.
Return value:
- visiblePhotos (array) never nil, but may be empty (e.g. virgin catalog)
-
- Catalog:initFolderCache (unInit)
-
Initialize folder cache to assure fresh results via (and set mode of) get-folder-by-path.
Parameters:
-
unInit
: (boolean, default = false) if false, get-folder-by-path will use cached mode (faster, but results will be stale unless care is taken to init before each "run"..).
if true, get-folder-by-path will use non-cached mode (slower, but results are always fresh).
-
- Catalog:initForOriginalFilenames ()
-
Determine if original filenames are even a possibility, and if so, prepare..
Return values:
- status - true iff successful
- message -- reason if not successful.
- Catalog:initSmartColls ()
- Initialize caches/lookups to be used by get-smart-colls.
- Catalog:isBuriedInStack (photo, bm)
-
Determine if specified photo is buried in collapsed stack in folder of origin.
Parameters:
-
photo
: lr-photo in question. -
bm
: batch (raw) metadata - optional.
-
- Catalog:isLocked (photo, orXmp, cache)
-
Determine if locked, and if so: return lock-date as string, as 2nd item in return list (1st item is boolean locked, or not).
Parameters:
-
photo
: lr-photo -
orXmp
: if photo not locked, also check if xmp is read-only. -
cache
:
Return values:
- locked true if so
- qualification may accompany *true* status: lock-date or xmp notice.
-
- Catalog:isMetadataColumnActive (metaIds, filter)
-
Determine if specified metadata columns are active in specified lib view filter.
Parameters:
-
metaIds
: array of strings -
filter
: view filter
Return value:
- true iff is active.
-
- Catalog:isMissing (photo, cache)
-
Determine if photo is missing - i.e. not physical file and no smart copy stub.
Parameters:
-
photo
: -
cache
:
Return values:
- status (boolean, always) true if photo source file does not exist.
- qualifier (string, sometimes) Note: it's not an error message (never set when false is returned), if accomanying 'true' status, it means smart preview exists.
-
- Catalog:isOriginalFilenamesInit ()
-
Determine if original filename subsystem is properly initialized.
Return value:
- file *iff* init'd sans issue.
- Catalog:isSmartPreview (photo, cache)
-
Determine if photo has a smart preview.
Parameters:
-
photo
: -
cache
:
Usage:
Previews object has a 'getSmartPreview' method, if you actually want to have the preview.
Return value:
- is (boolean) true or false.
-
- Catalog:new (t)
-
Constructor for new instance.
Parameters:
-
t
:
-
- Catalog:newClass (t)
-
Constructor for extending class.
Parameters:
-
t
:
-
- Catalog:readPhotoMetadata (photo, photoPath, alreadyInLibraryModule, service, manualSubtitle)
-
Read metadata for one photo.
Parameters:
-
photo
: - single photo object to read metadata for. -
photoPath
: - photo path. -
alreadyInLibraryModule
: - true iff library module has been assured before calling. -
service
: - if a scope in here it will be used for captioning. -
manualSubtitle
: - a tidbit for the prompt, if omitted it will be "this plugin needs metadata to be read".
Usage:
Not reliable in a loop without user prompting in between (or maybe lengthy delays).
Switch to grid mode first if necessary.
*** Side-effect of single photo selection - be sure to read previous multi-photo selection to restore afterward if necessary.
Ignores photos that are set to read-only, so make read-write before calling, if desired.
Uses keystroke emission to do the job.
Will not work on virtual copy (returns error message), so check before calling.
Return values:
- true iff metadata read
- error message if metadata not read.
-
- Catalog:refreshDisplay (photo, photoPath)
-
Refresh display of recently changed photo (externally changed).
Parameters:
-
photo
: -
photoPath
:
Usage:
If I remember correctly, this method does not work that well, so don't depend on it.
Theoretically, request-jpeg-thumbnail could be used to refresh display, except (as of Lr5.4) it doesn't work well enough either (ugh). -
- Catalog:restoreSelPhotos (selPhotos)
-
Restore previously saved photo selection and related settings.
Parameters:
-
selPhotos
: black box, as saved by save-sel-photos (yes: includes selected photos ;-}).
Usage:
call in cleanup handler if photo selection was changed temporarily by plugin.
cant deselect photos, so if nothing was selected in filmstrip before restoral, then restoral will just be a no-op.
-
- Catalog:saveMetadata (photos, preSelect, restoreSelect, alreadyInGridMode, service)
-
Save metadata for (multiple) specified photos.
Parameters:
-
photos
: - photos to save metadata for, or nil to do all target photos. -
preSelect
: - true to have specified photos selected before saving metadata, false if you are certain they are already selected. -
restoreSelect
: - true to have previously photo selections restored before returning. -
alreadyInGridMode
: - multiple photos requires grid mode, if already in it, for sure, set this to true. -
service
: - if a scope in here it will be used for captioning.
Usage:
Windows + Mac (its the *read* metadata that's not supported on mac).
Switch to grid mode first if desired, and select target photos first if possible.
Cause metadata conflict for photos that are set to read-only, so make read-write before calling, if desired.
Uses keystroke emission to do the job.
User will be prompted to first make sure the "Overwrite Settings" prompt will no longer appear.
Return values:
- true iff metadata saved.
- error message if metadata not saved.
-
- Catalog:savePhotoMetadata (photo, photoPath, targ, call, noVal, oldWay)
-
Save metadata for one photo.
Parameters:
-
photo
: - single photo object to save metadata for. -
photoPath
: - photo path (optional). -
targ
: - path to file containing xmp for save validation (optional). -
call
: - if a scope in call it will be used for captioning. -
noVal
: - don't validate that metadata is saved. -
oldWay
: - don't use buggy Lr5.2RC method.
Usage:
Windows + Mac (its the *read* metadata that's not supported on mac).
If you've just done something that needs settling before save, call sleep(e.g. .1) before this method to increase odds for success on first try.
Library mode is not necessary to save single photo metadata.
*** Side-effect of single photo selection - be sure to save previous multi-photo selection to restore afterward if necessary.
Will cause metadata conflict flag if xmp is read-only, so make read-write before calling, if desired.
Uses keystroke emission to do the job.
Return values:
- true iff metadata saved.
- error message if metadata not saved.
-
- Catalog:saveSelPhotos ()
-
Save selected photos, and related info/settings, for restoral later.
Usage:
call if photo selection will be changed temporarily by plugin.
- restore in cleanup handler.Return value:
- black box to pass to restoral function.
- Catalog:selectOnePhoto (photo)
-
select one photo, de-select all others - confirm selection.
Parameters:
-
photo
:
Usage:
For when photo is likely to be in filmstrip, otherwise use assure-photo-is-selected instead.
Will only select specified photo if not buried in stack, and not filtered out...
Return values:
- status (boolean, required) true => specified photo is only photo selected - confirmed.
- message (string or nil) qualification of failure.
-
- Catalog:selectPhoto (photo)
-
Make specified photo most selected, without changing other selections if possible.
Parameters:
-
photo
:
Usage:
photo source must already be active, or this won't work.
@3/May/2014 20:50, only plugin (of mine) using this method is SnapTrash.
Return values:
- status true if successful.
- message error message if unsuccessful.
-
- Catalog:selectPhotos (photo, photos, assureFolders, metaCache)
-
Set selected photos, and verify selection, with option to select folders if necessary to assure photos will be selected, even if not in filmstrip.
Parameters:
-
photo
: (LrPhoto, required) most selected. -
photos
: (array of LrPhotos, required) the rest, which must include most selected, unless assureSources is true. -
assureFolders
: (boolean, default=false) pass true to add photo to photos, if need be, and assure requisite sources are selected too - must be folders. -
metaCache
: (Cache, default=nil) pass a metadata cache to boost performance, if desired: must be populated with raw metadata for 'path' key, or it won't be worth anything.
Usage:
This function will also clear view filter if necessary to select photos - what it won't do is expand stacks.
Catalog photo selection may not take until processor is given up for Lightroom to do its thing.
If you must be certain selection has settled before continuing with processing, call
this method instead.Do not call this method, unless you know the photos are all in active sources, or if all from folders, set assure-sources. Presently, there is no method for assuring multiple selected photos from diverse (possibly not active) sources.
Will clear lib filter if need be, but will *not* unstack if need be, so stacking to exposes photos for selection must be handled externally, if needed.
Return values:
- status (boolean) true iff specified selection validated.
- message (string) error message if status is false.
-
- Catalog:setActiveSources (sources)
-
Set active sources, and verify all were properly set.
Parameters:
-
sources
: array of sources, must be settable via set-active-sources (e.g. catalog won't work, nor publish service, nor (I don't think) special collections.
Return values:
- status true iff all specified sources are active.
- error-message explanation if not.
-
- Catalog:setCollectionPhotos (coll, photos, tmo)
-
Set collection photos.
Parameters:
-
coll
: (lr-collection object, required) -
photos
: (array of lr-photos, required) may be empty, but may not be nil. -
tmo
: (number, optional) cat access tmo.
Usage:
auto-wrapped with cat-accessor if need be.
removes all photos from collection, then adds specified photos.
Return value:
- nil - throws error if problem.
-
- Catalog:setPropertyForPlugin (name, value, validate)
-
Set catalog metadata property if not already.
Parameters:
-
name
: (string, required) property name -
value
: (string | date | number | boolean, required) property value -
validate
: (boolean, default=false) if true, will read property back and compare to that which was set (left over from problem times - not necessary now, but won't hurt much either..).
Usage:
*** This is for setting catalog properties, NOT for setting photo properties (use metadata-manager for that).
Will wrap with async task if need be (in which case BEWARE: returns are always nil, and property is not guaranteed).
This mode appropriate for calling from plugin init module only.Will wrap with catalog access if need be.
Reminder: you can only set for current plugin - you can read for any plugin if you have its ID.
No errors are thrown - see status and error message for results.
*** property whose name is photo-uuid is reserved for background task.
Return value:
- nothing. throws error if problem.
-
- Catalog:update (tmo, name, func, ...)
-
Wrapper for named/undoable catalog:withWriteAccessDo method - divide to conquor func.
Parameters:
-
tmo
: (number) max seconds to get in. ***note: if > 1, user will be prompted to keep-trying (good for manually initiated ops). if <= 1, returns pronto (good for background processes which gracefully weather errors and retry naturally..). -
name
: (string) undo title. -
func
: (function) divided catalog writing function( context, phase, ... ): returns sts, msg = true when done; false if to be continued; nil, error message if trouble. -
...
: (any) additional parameters passed to func.
Usage:
example:
local function catUpdate( context, phase )
local i1 = ( phase - 1 ) * 1000 + 1
local i2 = math.min( phase * 1000, #photos )
for i = i1, i2 do
-- do something to photos[i]
-- if trouble, return nil, msg.
end
if i2 == #photos then
return true -- done, no errors.
else
return false -- continue, no errors.
end
end
local sts, msg = cat:update( 10, "Test", catUpdate )
if sts then
-- log successful message.
else
-- print error message...
endphase param can also be used to do things like add keyword (in phase 1), then use keyword (in phase 2).
Return values:
- status (boolean) true iff updated.
- message (string) accompanies un-true status to explain.
-
- Catalog:updatePrivate (tmo, func, ...)
-
Wrapper for un-named catalog:withPrivateWriteAccessDo method - divide to conquor func.
Parameters:
-
tmo
: (number) max seconds to get in. -
func
: (function) divided catalog writing function: returns sts, msg = true when done; false if to be continued; nil, error message if trouble. -
...
: (any) passed to func.
Usage:
AFAIC (despite Adobe documentation), this method is only good for updating custom plugin metadata (aka photo properties) - all others require full update.
see catalog--update method for example.
Return values:
- status (boolean) true iff updated.
- message (string) accompanies un-true status to explain.
-
- Catalog:withDo (tryCount, func, catalog, p1, p2, ...)
-
Catalog access wrapper that distinquishes catalog contention errors from target function errors.
Parameters:
-
tryCount
: Number of tries before giving up, at a half second per try (average). -
func
: Catalog with-do function. -
catalog
: The lr-catalog object. -
p1
: First parameter which may be a function, an action name, or a param table. -
p2
: Second parameter which will be a function or nil. -
...
: Additional function parameters
Usage:
*** deprecated - use cat update methods instead.
Returns immediately upon target function error.
The purpose of this function is so multiple concurrent tasks can access the catalog in succession without error.
Return values:
- status (boolean): true iff target function executed without error.
- other: function return value, or error message.
-
- Catalog:withRetries (tryCount, func, p1, p2, ...)
-
Catalog access wrapper that distinquishes catalog contention errors from target function errors.
Parameters:
-
tryCount
: Number of tries before giving up, at a half second per try (average). -
func
: Catalog with-do function. -
p1
: First parameter which may be a function, an action name, or a param table. -
p2
: Second parameter which will be a function or nil. -
...
: Additional function parameters
Usage:
*** deprecated - recommend update and/or update-private method instead.
Same as with-do method, except relies on global lr catalog.
Returns immediately upon target function error.
The purpose of this function is so multiple concurrent tasks can access the catalog in succession without error.
Return values:
- status (boolean): true iff target function executed without error.
- other: function return value, or error message.
-


Say hello to the future.
Design Film
Be the first to know. Sign up for our newsletter.
Joshua Rasberry claims no ownership of the products, brands, or intellectual property on this page.Theme based on Apple's website.


| sparkR.init {SparkR} | R Documentation |
This function initializes a new SparkContext.
sparkR.init(master = "", appName = "SparkR", sparkHome = Sys.getenv("SPARK_HOME"), sparkEnvir = list(), sparkExecutorEnv = list(), sparkJars = "", sparkRLibDir = "", sparkPackages = "")
master |
The Spark master URL. |
appName |
Application name to register with cluster manager |
sparkHome |
Spark Home directory |
sparkEnvir |
Named list of environment variables to set on worker nodes. |
sparkExecutorEnv |
Named list of environment variables to be used when launching executors. |
sparkJars |
Character string vector of jar files to pass to the worker nodes. |
sparkRLibDir |
The path where R is installed on the worker nodes. |
sparkPackages |
Character string vector of packages from spark-packages.org |
## Not run:
##D sc <- sparkR.init("local[2]", "SparkR", "/home/spark")
##D sc <- sparkR.init("local[2]", "SparkR", "/home/spark",
##D list(spark.executor.memory="1g"))
##D sc <- sparkR.init("yarn-client", "SparkR", "/home/spark",
##D list(spark.executor.memory="1g"),
##D list(LD_LIBRARY_PATH="/directory of JVM libraries (libjvm.so) on workers/"),
##D c("jarfile1.jar","jarfile2.jar"))
## End(Not run)