我想为spplot()上的区域添加名称标签.
例:
load(url('http://gadm.org/data/rda/FRA_adm0.RData'))
FR <- gadm
FR <- spChFIDs(FR, paste("FR", rownames(FR), sep = "_"))
load(url('http://gadm.org/data/rda/CHE_adm0.RData'))
SW <- gadm
SW <- spChFIDs(SW, paste("SW", rownames(SW), sep = "_"))
load(url('http://gadm.org/data/rda/DEU_adm0.RData'))
GE <- gadm
GE <- spChFIDs(GE, paste("GE", rownames(GE), sep = "_"))
df <- rbind(FR, SW, GE)
## working
plot(df)
text(getSpPPolygonsLabptSlots(df), labels = c("FR", "SW", "GE"))
## not working
spplot(df[1-2,])
text((getSpPPolygonsLabptSlots(df), labels = c("FR", "SW"))
Run Code Online (Sandbox Code Playgroud)
第二个可能因为格子而无法工作!?但是,我需要spplot功能.我如何获得情节上的标签?
我正在研究java HashMaps,发现它将值添加到列表的头部.例如 ,
hm.put(麦克,2); hm.put(安德鲁,3);
现在,如果我使用迭代器打印hasmap,我得到
安德鲁3
迈克2
我希望以FIFO方式而不是LIFO方式添加项目......有没有办法做到这一点?
将C预处理器多次应用于同一代码库(具体来说,按顺序执行两次?)是否可以远程理解?
例如,具有如下声明:
##define DECLARE(FILE) # define DECLARATIONS \
# include FILE \
# undef DECLARATIONS
Run Code Online (Sandbox Code Playgroud)
你以前见过这样的成语吗?如果是这样,代码库是什么?你能链接吗?编译一个像这样的项目的项目会遵循什么样的模式?可以按原样使CPP执行此操作,还是需要编写元预处理器以在处理双哈希声明时"隐藏"单哈希声明,依此类推?
我正在尝试在Ubuntu 10.10上为curl(curb)安装ruby gem,但在安装过程中,我收到错误:
/usr/bin/ld: cannot find -lcurl
Run Code Online (Sandbox Code Playgroud)
但卷曲安装!apt-get install curl说我有最新版本.也没有curl-dev.
我一直都会遇到这些错误,包括curl,libxml,readline,我不知道发生了什么.我的Ubuntu安装有问题,但我不知道什么,我不知道在哪里看,我不知道谷歌的用途,我不知道如何修复它.
帮助将深表感谢.
编辑:这是在libcurl的/ usr/lib目录中:
lrwxrwxrwx 1 root root 19 2011-02-18 23:15 libcurl-gnutls.so.3 -> libcurl-gnutls.so.4
lrwxrwxrwx 1 root root 23 2011-02-18 23:15 libcurl-gnutls.so.4 -> libcurl-gnutls.so.4.2.0
-rw-r--r-- 1 root root 339880 2010-06-23 09:07 libcurl-gnutls.so.4.2.0
lrwxrwxrwx 1 root root 12 2011-02-18 23:14 libcurl.so.3 -> libcurl.so.4
lrwxrwxrwx 1 root root 16 2011-02-18 23:14 libcurl.so.4 -> libcurl.so.4.2.0
-rw-r--r-- 1 root root 360904 2010-06-23 09:07 libcurl.so.4.2.0
Run Code Online (Sandbox Code Playgroud) 我为我的注释设置了自定义pinImage,当我将类型更改为MKMapTypeHybrid它时,将pinImage设置恢复为标准引脚.
我viewWillAppear在地图视图控制器的方法中设置了mapType .我正在为这样的注释设置我的pinImage(为了清晰起见缩短了):
- (MKAnnotationView *) mapView:(MKMapView *) mapView viewForAnnotation:(id ) annotation {
MKPinAnnotationView *customAnnotationView=[[[MKPinAnnotationView alloc]
initWithAnnotation:annotation
reuseIdentifier:@"markerAnnotationView"] autorelease];
UIImage *pinImage = [UIImage imageNamed:@"/pin-image"];
[customAnnotationView setImage:pinImage];
return customAnnotationView;
}
Run Code Online (Sandbox Code Playgroud)
有没有办法setImage通过代码使用和设置mapType?
我在routes.db文件中有这个代码:
resources :users do
member do
get :following, :followers
end
end
Run Code Online (Sandbox Code Playgroud)
我收到错误:
can't use member outside resource(s) scope (ArgumentError)
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
更新:这是我的routes.db文件的所有代码:
SampleApp::Application.routes.draw do
get "sessions/new"
resources :users
member do
get :following, :followers
end
resources :sessions, :only => [:new, :create, :destroy]
resources :microposts, :only => [:create, :destroy]
resources :relationships, :only => [:create, :destroy]
match '/signup', :to => 'users#new'
match '/signin', :to => 'sessions#new'
match '/signout', :to => 'sessions#destroy'
match '/contact', :to => 'pages#contact'
match '/about', :to => 'pages#about'
match '/help', :to …Run Code Online (Sandbox Code Playgroud) 我的send()和recv()看起来像这样:
int Send(const char* buffer, int size)
{
cout << "SIZE: " << size << endl;
int offset;
while(offset < size)
{
int n = ::send(getSocket(), buffer + offset, size - offset, 0);
if(n == SOCKET_ERROR)
{
break;
}
offset += n;
if(offset != size)
{
Sleep(1);
}
}
return offset;
}
int Recv(char* buffer, int size)
{
int n = ::recv(getSocket(), buffer, size, 0);
if(n == SOCKET_ERROR)
{
cout << "Error receiving data" << endl;
}
if(n == 0) …Run Code Online (Sandbox Code Playgroud) 假设有一个脚本做这样的事情:
# module writer.py
import sys
def write():
sys.stdout.write("foobar")
Run Code Online (Sandbox Code Playgroud)
现在假设我想捕获write函数的输出并将其存储在变量中以供进一步处理.天真的解决方案是:
# module mymodule.py
from writer import write
out = write()
print out.upper()
Run Code Online (Sandbox Code Playgroud)
但这不起作用.我想出了另一个解决方案并且它有效,但是请告诉我是否有更好的方法来解决问题.谢谢
import sys
from cStringIO import StringIO
# setup the environment
backup = sys.stdout
# ####
sys.stdout = StringIO() # capture output
write()
out = sys.stdout.getvalue() # release output
# ####
sys.stdout.close() # close the stream
sys.stdout = backup # restore original stdout
print out.upper() # post processing
Run Code Online (Sandbox Code Playgroud) 我有以下用剃须刀编写的ASP.NET MVC页面:
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<title>SelectorTests</title>
<link href="@{ Url.Content("~/Content/themes/base/jquery-ui.css"); }" rel="stylesheet" type="text/css" />
<script src="@{ Url.Content("~/Scripts/jquery-1.4.4.min.js"); }" type="text/javascript"></script>
<script src="@{ Url.Content("~/Scripts/jquery-ui.min.js"); }" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$('h1').css('background-color', 'purple');
});
</script>
</head>
<body>
<div>
<h1>My Header</h1>
foobar
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
URL.Content无法正常工作.当我在FF中执行查看源时,相关的行返回为
<link href="" rel="stylesheet" type="text/css" />
<script src="" type="text/javascript"></script>
<script src="" type="text/javascript"></script>
Run Code Online (Sandbox Code Playgroud)
请协助.
第一次在这里问一个问题.我希望帖子清晰,示例代码格式正确.
我正在尝试AVFoundation和时间推移摄影.
我的目的是从iOS设备(我的iPod touch,版本4)的摄像机中抓取每个第N帧,并将每个帧写入文件以创建游戏中时光倒流.我正在使用AVCaptureVideoDataOutput,AVAssetWriter和AVAssetWriterInput.
问题是,如果我使用CMSampleBufferRef传递给
captureOutput:idOutputSampleBuffer:fromConnection:,每帧的回放是原始输入帧之间的时间长度.帧率为1fps.我希望得到30fps.
我试过用了
CMSampleBufferCreateCopyWithNewTiming(),但随后将13帧写入文件后,
captureOutput:idOutputSampleBuffer:fromConnection:停止被叫.界面处于活动状态,我可以点击按钮停止捕获并将其保存到照片库进行播放.它看起来像我想要的那样回放,30fps,但它只有那13帧.
如何实现30fps播放的目标?如何判断应用程序丢失的原因以及原因?
我已经放置了一个名为useNativeTime的标志,因此我可以测试这两种情况.当设置为YES时,我得到所有我感兴趣的帧,因为回调不会"迷路".当我将该标志设置为NO时,我只处理了13帧,并且再也没有返回到该方法.如上所述,在这两种情况下我都可以播放视频.
谢谢你的帮助.
这是我正在尝试重新定时的地方.
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection
{
BOOL useNativeTime = NO;
BOOL appendSuccessFlag = NO;
//NSLog(@"in captureOutpput sample buffer method");
if( !CMSampleBufferDataIsReady(sampleBuffer) )
{
NSLog( @"sample buffer is not ready. Skipping sample" );
//CMSampleBufferInvalidate(sampleBuffer);
return;
}
if (! [inputWriterBuffer isReadyForMoreMediaData])
{
NSLog(@"Not ready for data.");
}
else {
// Write every first frame of n frames (30 native from camera).
intervalFrames++;
if (intervalFrames > …Run Code Online (Sandbox Code Playgroud)