GMap.Net cache only mode doesn't really care about the cache path I specify - offline-caching

This is my code:
gMapControl1.MapProvider = GMapProviders.GoogleTerrainMap;
gMapControl1.Manager.Mode = GMap.NET.AccessMode.CacheOnly;
var filePath = #"C:\Users\User\Documents\Projects\Data.gmdb";
var fileExists = File.Exists(filePath); //this is true
var outcome = gMapControl1.Manager.ImportFromGMDB(filePath); //this is true as well
gMapControl1.MinZoom = 0;
gMapControl1.MaxZoom = 24;
gMapControl1.Zoom = 9;
gMapControl1.ShowCenter = false;
However, when I step through the code via a debugger, I see that gMapControl1.Manager.PrimaryCache.CacheLocation is still %appdata%Local\GMap.NET ( I think this is the default cache location), and gMapControl1.Manager.SecondaryCache is null.
I cannot find my cache path registered anywhere in GMap.net. Any idea why?
It seems that ImportFromGMDB isn't really functioning as it should.

To use the CacheOnly Mode you have to set the CacheLocation property which is the directory that GMap will Read\Write Cached\New tiles.
gMapControl1.MapProvider = GMapProviders.GoogleTerrainMap;
gMapControl1.Manager.Mode = GMap.NET.AccessMode.CacheOnly;
gMapControl1.CacheLocation = "[Cache_Directory]";
*[Cache_Directory]: can be any directory you want, like: C:\Tiles
Try this approach and the CacheOnly mode will work.

Related

main.lua:25:attempt to call method'setanchorPoint'(a nil value)stack traceback:main.lua25:in maiin chunk

I am geeting an error: main.lua:25:attempt to call method'setanchorPoint'(a nil value)stack traceback:main.lua25:in maiin chunk. Please tell me how can I use anchorPoint. And how to resolve this issue
--constants
_H = display.contentHeight;
_W = display.contentWidth;
mRand = math.random;
o = 0;
time_remain = 10;
time_up = false;
total_orbs = 20;
ready = false;
--Prepare sounds to be played or accessed
local soundtrack = audio.loadStream("media/soundtrack.caf");
local pop_sound = audio.loadSound("media/pop.caf");
local win_sound = audio.loadSound("media/win.caf");
local fail_sound = audio.loadSound("media/fail.caf");
local display_txt = display.newText("Wait", 0, 0, native.systemFont, 16*2);
display_txt.xScale = .5; display_txt.yScale = .5;
display_txt:setanchorPoint(display.BottomLeftanchorPoint);
display_txt.x = 20; display_txt.y = _H-20;
If you want to know how to use anchor points in Corona, the usual approach is to refer to the Corona manual....
Corona Anchor Guide
Anchors
The anchor of an object controls how geometry is positioned
relative to the object's origin. This is specified via the
object.anchorX and object.anchorY properties.
They even give examples....
You cannot just invent function names and wonder why you get error messages for callinig them.

ParamValidationExt error with WelsInitEncoderExt failed while setting up OpenH264 encoder

Scenario:
I am using OpenH264 with my App to encode into a video_file.mp4.
Environment:
Platform : MacOs Sierra
Compiler : Clang++
The code:
Following is the crux of the code I have:
void EncodeVideoFile() {
ISVCEncoder * encoder_;
std:string video_file_name = "/Path/to/some/folder/video_file.mp4";
EncodeFileParam * pEncFileParam;
SEncParamExt * pEnxParamExt;
float frameRate = 1000;
EUsageType usageType = EUsageType::CAMERA_VIDEO_REAL_TIME;
bool denoise = false;
bool lossless = true;
bool enable_ltr = false;
int layers = 1;
bool cabac = false;
int sliceMode = 1;
pEncFileParam = new EncodeFileParam;
pEncFileParam->eUsageType = EUsageType::CAMERA_VIDEO_REAL_TIME;
pEncFileParam->pkcFileName = video_file_name.c_str();
pEncFileParam->iWidth = frame_width;
pEncFileParam->iHeight = frame_height;
pEncFileParam->fFrameRate = frameRate;
pEncFileParam->iLayerNum = layers;
pEncFileParam->bDenoise = denoise;
pEncFileParam->bLossless = lossless;
pEncFileParam->bEnableLtr = enable_ltr;
pEncFileParam->bCabac = cabac;
int rv = WelsCreateSVCEncoder (&encoder_);
pEnxParamExt = new SEncParamExt;
pEnxParamExt->iUsageType = pEncFileParam->eUsageType;
pEnxParamExt->iPicWidth = pEncFileParam->iWidth;
pEnxParamExt->iPicHeight = pEncFileParam->iHeight;
pEnxParamExt->fMaxFrameRate = pEncFileParam->fFrameRate;
pEnxParamExt->iSpatialLayerNum = pEncFileParam->iLayerNum;
pEnxParamExt->bEnableDenoise = pEncFileParam->bDenoise;
pEnxParamExt->bIsLosslessLink = pEncFileParam->bLossless;
pEnxParamExt->bEnableLongTermReference = pEncFileParam->bEnableLtr;
pEnxParamExt->iEntropyCodingModeFlag = pEncFileParam->bCabac ? 1 : 0;
for (int i = 0; i < pEnxParamExt->iSpatialLayerNum; i++) {
pEnxParamExt->sSpatialLayers[i].sSliceArgument.uiSliceMode = pEncFileParam->eSliceMode;
}
encoder_->InitializeExt(pEnxParamExt);
int videoFormat = videoFormatI420;
encoder_->SetOption (ENCODER_OPTION_DATAFORMAT, &videoFormat);
int frameSize = frame_width * frame_height * 3 / 2;
int total_num = 500;
BufferedData buf;
buf.SetLength (frameSize);
// check the buffer before proceeding
if (buf.Length() != (size_t)frameSize) {
CloseEncoder();
return;
}
SFrameBSInfo info;
memset (&info, 0, sizeof (SFrameBSInfo));
SSourcePicture pic;
memset (&pic, 0, sizeof (SSourcePicture));
pic.iPicWidth = frame_width;
pic.iPicHeight = frame_height;
pic.iColorFormat = videoFormatI420;
pic.iStride[0] = pic.iPicWidth;
pic.iStride[1] = pic.iStride[2] = pic.iPicWidth >> 1;
pic.pData[0] = buf.data();
pic.pData[1] = pic.pData[0] + frame_width * frame_height;
pic.pData[2] = pic.pData[1] + (frame_width * frame_height >> 2);
for(int num = 0; num < total_num; num++) {
// try to encode the frame
rv = encoder_->EncodeFrame (&pic, &info);
}
if (encoder_) {
encoder_->Uninitialize();
WelsDestroySVCEncoder (encoder_);
}
}
Above code is something I pulled up from official usage examples of OpenH264 where BufferedData.h is a class I reused from OpenH264 utils
Issue:
But, I am getting the following error:
[OpenH264] this = 0x0x1038bc8c0, Error:ParamValidationExt(), width > 0, height > 0, width * height <= 9437184, invalid 0 x 0 in dependency layer settings!
[OpenH264] this = 0x0x1038bc8c0, Error:WelsInitEncoderExt(), ParamValidationExt failed return 2.
[OpenH264] this = 0x0x1038bc8c0, Error:CWelsH264SVCEncoder::Initialize(), WelsInitEncoderExt failed.
Above does not crash the application but it goes through a blank run without creating the video_file.mp4 with the dummy data that I am trying to write into it.
Question:
There seems to be something wrong with the set up config I applying to pEnxParamExtwhich goes into encoder_->InitializeExt.
What am I doing wrong with the set up of the encoder?
Note:
I am not trying to hook up to any camera device. I am just trying to create a .mp4 video out of some dummy image data.
If you want to get complete and working OpenH264 Encoder Initialization procedure you can click... here.
According to your problem scenario, you are trying to create a video file(.mp4/.avi) from some dummy images. This task can be accomplished using two different libraries: i) Library for Codec, ii) Library for Container.
i) Library for Codec: It's so much easy to use a OpenH264 to compress data. One thing I must mention is that, OpenH264 always works with raw frames e.g. yuv420 data. So, if you want to compress your image data, you have to convert these image data into yuv420 color format. To get OpenH264 click... here
ii) Library for Container: After getting the encoded data you have to use another library to create the container with extension .mp4, .avi, .flv etc. There exists a lot of libraries in github to do that staff like FFmpeg, OpenCV, Bento4, MP4Maker, mp4parser etc. Before using these libraries please check in detail about the license issues. If you use FFmpeg, you will not need to use OpenH264 becuse FFmpeg itself works along with several codecs. You will also find lot more working examples as so many developers are working with video data out there.
Hope it helps. :)

Google Apps Script

I've created a simple script that reads through an xml file and posts the results to an SQL database. This works perfectly.
I've put a little if statement in the script to identify orders that have already been posted to SQL. Basically if the transactionID in the input array is higher than the highest transactionID on the SQL server it adds the row values to the output array.
It seems that I am missing a trick here because I am getting "TypeError: Cannot call method "getAttribute" of undefined. (line 18, file "Code")" when trying to compare the current xml row to the last transaction ID.
I've done some searching and whilst I can see people with similar problems the explanations don't make a whole lot of sense to me.
Anyway, here is the relevant part of the code. Note that this all works perfectly without the if() bit.
function getXML() {
var id = lastTransactionID();
var xmlSite = UrlFetchApp.fetch("https://api.eveonline.com/corp/WalletTransactions.xml.aspx?KeyID=1111&vCode=1111&accountKey=1001").getContentText();
var xmlDoc = XmlService.parse(xmlSite);
var root = xmlDoc.getRootElement();
var row = new Array();
row = root.getChild("result").getChild("rowset").getChildren("row");
var output = new Array();
var i = 0;
for (j=0;i<row.length;j++){
if(row[j].getAttribute("transactionID").getValue()>id){ //Produces: TypeError: Cannot call method "getAttribute" of undefined. (line 18, file "Code")
output[i] = new Array();
output[i][0] = row[j].getAttribute("transactionDateTime").getValue();
output[i][1] = row[j].getAttribute("transactionID").getValue();
output[i][2] = row[j].getAttribute("quantity").getValue();
output[i][3] = row[j].getAttribute("typeName").getValue();
output[i][4] = row[j].getAttribute("typeID").getValue();
output[i][5] = row[j].getAttribute("price").getValue();
output[i][6] = row[j].getAttribute("clientID").getValue();
output[i][7] = row[j].getAttribute("clientName").getValue();
output[i][8] = row[j].getAttribute("stationID").getValue();
output[i][9] = row[j].getAttribute("stationName").getValue();
output[i][10] = row[j].getAttribute("transactionType").getValue();
output[i][11] = row[j].getAttribute("transactionFor").getValue();
output[i][12] = row[j].getAttribute("journalTransactionID").getValue();
output[i][13] = row[j].getAttribute("clientTypeID").getValue();
i++;
}
}
insert(output,output.length);
}
I have seen my mistake and corrected.
Mistake was in the for loop.
for (j=0;i

Resizing images - Symfony

I have a number of images that are sotred as blob data in my database.
I am aware this isn't a good idea, but it's what I'm using.
I have following code in my Peer class:
public function getImagesPath()
{
$file_srcs = false;
$fp = $this->getPhoto->getBlobData();
if ($fp !== null)
{
$file = stream_get_contents($fp);
$file_srcs = '/uploads/gallery/'.$this->getId().'.jpg';
}
return $file_srcs;
}
I then call this in my template, like so:
$path = $item->getImagesPath();
if ($path)
{
echo '<img src="'.$path.'" alt="Thumbnail for '.$photo->getName().'" width="153" height="153" />';
}
Now this works well, but, I have some images that are either square in shape, or rectangular.
Giving them a size/width in the img src distorts some of them.
Is there anyway, in which I could resize/crop the images before they are displayed?
Thanks
sfThumbnailPlugin is what I've used on a number of projects and it is pretty awesome. There is an older version for Symfony 1.0 if that's what you're using. By default it uses GD, but you can have it use ImageMagick and do some pretty cool things with it.
You can probably use imagecreatefromstring and imagecopyresampled. This is code that I use, that I've changed to work with your blob. This also adds a white background if the original size width/height ratio doesn't match the destination image size.
static function CreateThumbnailFromBlob($blobData, $dstWidth = 100.0, $dstHeight = 100.0){
$oldImg = #imagecreatefromstring($olduri);
if($oldImg){
$realOldW = imagesx($oldImg);
$realOldH = imagesy($oldImg);
$destX = 0;
$destY = 0;
if($realOldH>=$realOldW && $realOldH>0){
$realY = $dstHeight;
$realX = round($realY*$realOldW/$realOldH);
$destX = round($dstWidth/2-$realX/2);
}else{
$realX = $dstWidth;
if($realOldW>0)
$realY = round($realX*$realOldH/$realOldW);
else
$realY = $dstHeight;
$destY = round($dstHeight/2-$realY/2);
}
$newImg = #imagecreatetruecolor($dstWidth, $dstHeight);
$white = imagecolorallocate($newImg, 255, 255, 255);
imagefill($newImg, 1, 1, $white);
imagecopyresampled($newImg,$oldImg,$destX,$destY,
0,0,$realX,$realY,$realOldW,$realOldH);
imagedestroy($oldImg);
return $newImg;
}
}
How are you adding images to the database?
If it is via an upload form, the best method would be to create a thumbnail of the appropriate size/dimensions using GD or another library and store it in a second blob column.
Otherwise you can specify a single dimension in the html and the picture will retain its dimensions.

Programmatically added SummaryLinkWebPart doesn't display Links

I am using below code to Add SummaryLinkWebPart to a Page and also adding few links to that wehbpart. I can see the webpart now on the page but it doesn't have any links inside it. Does anyone know what is wrong with the code?
var wpm = web.GetLimitedWebPartManager("Pages/default.aspx", PersonalizationScope.Shared);
SummaryLinkWebPart slwp = new SummaryLinkWebPart();
for (int counter = 0; counter < list.ItemCount; counter++)
{
urlField = list.Items[counter]["URL"].ToString().Split(',');
SummaryLink link = new SummaryLink(urlField[1].Trim());
slwp.SummaryLinkValue.SummaryLinks.Add(link);
slwp.SummaryLinkValue.SummaryLinks[counter].OpenInNewWindow = true;
slwp.SummaryLinkValue.SummaryLinks[counter].LinkUrl = urlField[0].Trim();
slwp.SummaryLinkValue.SummaryLinks[counter].Description = urlField[1];
slwp.Style = "Image on left";
Console.WriteLine(link.LinkUrl + link.Title);
}
wpm.AddWebPart(slwp, lvwp.ZoneID, slwp.ZoneIndex + 1);
Hmm this seems to be the hack but the only thing that solves this issue is reassigning the SummaryLinkValue Property back again its value.
slwp.SummaryLinkValue = slwp.SummaryLinkValue;
use
SPLimitedWebPartManager wpManager = page.GetLimitedWebPartManager(System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
then when done call page.Update(). something like this
SPFile page = web.GetFile(string.Format("Pages/{0}", this.FileName.Replace("html", "aspx")));
SPLimitedWebPartManager wpManager = page.GetLimitedWebPartManager(System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
SummaryLinkWebPart webpart = new SummaryLinkWebPart();
if (!string.IsNullOrEmpty(RelatedTopic1))
webpart.SummaryLinkValue.SummaryLinks.Add(GetSummaryLink(web, pages, RelatedTopic1));
if (!string.IsNullOrEmpty(RelatedTopic2))
webpart.SummaryLinkValue.SummaryLinks.Add(GetSummaryLink(web, pages, RelatedTopic2));
if (!string.IsNullOrEmpty(RelatedTopic3))
webpart.SummaryLinkValue.SummaryLinks.Add(GetSummaryLink(web, pages, RelatedTopic3));
if (!string.IsNullOrEmpty(RelatedTopic4))
webpart.SummaryLinkValue.SummaryLinks.Add(GetSummaryLink(web, pages, RelatedTopic4));
if (webpart.SummaryLinkValue.SummaryLinks.Count > 0)
{
wpManager.AddWebPart(webpart, "BottomPanel", 0);
page.Update();
}

Resources