DECLARE @xml XML,
@rawXml VARCHAR(MAX)
SET @rawXml = '<parent><child /><parent>'
SET @xml = CONVERT(XML, @rawXml)
-- Get the root element name
SELECT DISTINCT c.value('local-name(.)', 'nvarchar(50)') RootName
FROM @xml.nodes('/*') AS r(c)
-- Get the root child element name
SELECT DISTINCT c.value('local-name(.)', 'nvarchar(50)') RootChild
FROM @xml.nodes('/*/*') AS r(c)
SyntaxHighlighter
Tuesday, June 19, 2012
T-SQL: Get XML element names
The following little code snippet retrieves the XML element names of the nodes at the respective levels. The first query returns the root node name, and the second the root child node name.
Saturday, May 26, 2012
Entity Framework: Invalid column name 'xxx'
I was busy toying with Entity Framework (EF) and some SQL change scripts when I received this error:
This is how the error occurred: I created my EF data model, dropped the database, added 'FullName' to one of my tables, and updated my data model.
Clearly EF lost a mapping or some DB specific configuration setting. I poked around the web for a while and could not find the exact cause. Some claims point towards schema types or collation settings.
Unfortunately, I don't have the time to figure this one out, so I removed my EF data model and its connection strings in the app.config and recreated it. This resolved the issue, but I have that uneasy feeling this is going to come back to bite me again.
SqlException (0x80131904): Invalid column name 'FullName'.
This is how the error occurred: I created my EF data model, dropped the database, added 'FullName' to one of my tables, and updated my data model.
Clearly EF lost a mapping or some DB specific configuration setting. I poked around the web for a while and could not find the exact cause. Some claims point towards schema types or collation settings.
Unfortunately, I don't have the time to figure this one out, so I removed my EF data model and its connection strings in the app.config and recreated it. This resolved the issue, but I have that uneasy feeling this is going to come back to bite me again.
Wednesday, May 16, 2012
Handle HTTP Form Post requests with a WCF service
I have been spending a lot of time working with WCF of late and one of my goals were to build an interface capable of handling HTTP Post requests. My inspiration comes from the fantastically simple implementation by Stripe:
Let's see how we can create a similar implementation using WCF.
In Visual Studio 2010, create a new WCF Service Application, which we're going to call the Network. The following files will be created within your project:
The key here is to add the WebInvoke attribute. The UriTemplate indicates which URL will be mapped to this particular method call. In our case, Ping(...) will be executed if any HTTP Post request is sent to http://localhost:port/service1.svc/ping.
Next we need to implement our service. Essentially we are just pinging our service with some message which will be echoed back.
All we need to do now is to configure our service in the web.config. The key here is to create a webHttpBinding endpoint with a corresponding webHttp endpointBehavior:
Now we can run our service. For consistency, we'll use the VS Development Server as our host and specify a static port. Go into the project properties, select the Web tab and set the Specific Port to 8000.
Set your Service.svc as the start page, and build and debug.
You can either create a plain HTML page with a form that posts to your service or you can use a tool such as curl to do a submission. Let's put it to the test:
Success!
curl https://api.stripe.com/v1/charges \ -u vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE: \ -d amount=400 \ -d currency=usd \ -d "description=Charge for site@stripe.com" \ -d "card[number]=4242424242424242" \ -d "card[exp_month]=12" \ -d "card[exp_year]=2012" \ -d "card[cvc]=123"
Let's see how we can create a similar implementation using WCF.
In Visual Studio 2010, create a new WCF Service Application, which we're going to call the Network. The following files will be created within your project:
- IService1.cs Your service contract
- Service1.svc The service implementation
- Web.config Your service configuration information
You can rename these, but I'll leave them as they are, since renaming them can cause complications later on.
Let's start with our service interface. By default VS will generate two service methods (GetData and GetDataUsingDataContract) and a class called CompositeType. You can remove the methods and class and replace it with the following:
Let's start with our service interface. By default VS will generate two service methods (GetData and GetDataUsingDataContract) and a class called CompositeType. You can remove the methods and class and replace it with the following:
using System.IO;
using System.ServiceModel;
using System.ServiceModel.Web;
namespace Network
{
[ServiceContract]
public interface IService1
{
[OperationContract]
[WebInvoke(UriTemplate = "ping")]
string Ping(Stream input);
}
}
The key here is to add the WebInvoke attribute. The UriTemplate indicates which URL will be mapped to this particular method call. In our case, Ping(...) will be executed if any HTTP Post request is sent to http://localhost:port/service1.svc/ping.
Next we need to implement our service. Essentially we are just pinging our service with some message which will be echoed back.
using System;
using System.Collections.Specialized;
using System.IO;
using System.Web;
namespace Network
{
public class Service : IService1
{
public string Ping(Stream input)
{
var streamReader = new StreamReader(input);
string streamString = streamReader.ReadToEnd();
streamReader.Close();
NameValueCollection nvc = HttpUtility.ParseQueryString(streamString);
return string.IsNullOrEmpty(nvc["message"])
? "The 'message' key value pair was not received."
: nvc["message"];
}
}
}
All we need to do now is to configure our service in the web.config. The key here is to create a webHttpBinding endpoint with a corresponding webHttp endpointBehavior:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="webEndpointBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="Network.Service1">
<endpoint address=""
behaviorConfiguration="webEndpointBehavior"
binding="webHttpBinding"
bindingConfiguration=""
contract="Network.IService1"/>
</service>
</services>
</system.serviceModel>
</configuration>
Now we can run our service. For consistency, we'll use the VS Development Server as our host and specify a static port. Go into the project properties, select the Web tab and set the Specific Port to 8000.
Set your Service.svc as the start page, and build and debug.
You can either create a plain HTML page with a form that posts to your service or you can use a tool such as curl to do a submission. Let's put it to the test:
c:\>curl http://localhost:8000/service1.svc/ping -d message=pong "pong"
Success!
Update:
If you'd like to test this solution from a web page, you can use the following bit of HTML code:
<html>
<body>
<form action="http://localhost:8000/service1.svc/ping" method="post">
<input name="message" type="text" value="pong" />
<input type="submit" />
</form>
</body>
</html>
The response received is:
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">pong</string>One might want to get rid of the tags around the response string as well, but I'll get back to that in another post.
Sunday, June 12, 2011
VSTO: Changes to Zoom percentage not persisted
I have been playing around with VSTO and for some odd reason, my zoom percentage changed to 10% and any subsequent changes to the zoom percentage were not persisted. Using Google's Code Search, I found some examples of how to change these settings in the code-behind:
But it is still annoying when going into design-mode and having to zoom in again.
One way to fix this is to close Visual Studio, create a copy of the docx file, make the necessary changes and replace the old file.
this.ActiveWindow.View.Type = Word.WdViewType.wdPrintView;
this.ActiveWindow.View.Zoom.Percentage = 100;
But it is still annoying when going into design-mode and having to zoom in again.
One way to fix this is to close Visual Studio, create a copy of the docx file, make the necessary changes and replace the old file.
Tuesday, February 8, 2011
WCF: Programmatically set dataContractSerializer's maxItemsInObjectGraph value
When programmtically setting up a WCF Client, one often have to set the dataContractSerializer's maxItemsInObjectGraph parameter (within the serviceBehaviors) to a higher value than the default 65536.
I struggled a bit to find this one on-line, but finally came across a solution on here.
Here's the way to do it:
Where the myClient object is an instance of the ServiceClient.
I struggled a bit to find this one on-line, but finally came across a solution on here.
Here's the way to do it:
foreach (OperationDescription operation in myClient.Contract.Operations)
operation.Behaviors.Find<DataContractSerializerOperationBehavior>().MaxItemsInObjectGraph = 2147483646;
Where the myClient object is an instance of the ServiceClient.
Sunday, April 25, 2010
IIS 7 and SSL Error
If ever faced with the error ssl_error_rx_record_too_long in IIS 7, check to see if you have IIS 6 Compatibility switched on (Control Panel -> Programs and Features -> Turn Windows features on or off -> Internet Information Services -> Web Management Tools -> IIS 6 Management Compatibility).
Monday, March 29, 2010
WPF: Dynamically create a Table
Being new to WPF, there are a few funnies you'd need to know about before being able to create a simple table with text.
First, one can't simply add a Table within a Grid container. Tables need to be housed within a FlowDocument. One also need a container to display these FlowDocuments. I found the FlowDocumentScrollViewer to be the simplest. Some code to display a blank table:
To populate the table programmatically with some basic text one need to follow the next procedure (the code is pretty much self-explanatory):
I must say that this approach (a Run within a Paragraph within a TableCell within a Row within a RowGroup) isn't terribly intuitive and the process seems a bit tedious when only trying to create a simple table.
First, one can't simply add a Table within a Grid container. Tables need to be housed within a FlowDocument. One also need a container to display these FlowDocuments. I found the FlowDocumentScrollViewer to be the simplest. Some code to display a blank table:
<FlowDocumentScrollViewer
VerticalScrollBarVisibility="Disabled"
HorizontalScrollBarVisibility="Disabled">
<FlowDocument>
<Table Name="myTable"></Table>
</FlowDocument>
</FlowDocumentScrollViewer>
To populate the table programmatically with some basic text one need to follow the next procedure (the code is pretty much self-explanatory):
int cols = 5;
int rows = 10;
for (int c = 0; c < cols; c++)
myTable.Columns.Add(New TableColumn());
for (int r = 0; r < rows; r++)
{
TableRow tr = new TableRow();
for (int c = 0; c < cols; c++)
tr.Cells.Add(New TableCell(New Paragraph(New Run("Some Text"))));
TableRowGroup trg = new TableRowGroup();
trg.Rows.Add(tr);
myTable.RowGroups.Add(trg);
}
I must say that this approach (a Run within a Paragraph within a TableCell within a Row within a RowGroup) isn't terribly intuitive and the process seems a bit tedious when only trying to create a simple table.
Thursday, December 10, 2009
C#: Calling/Overriding Grandparent Base Class Methods
I use a base class for 99% of my ASP.Net pages, which executes a few operations in the OnInit() method. Here's a simplified version:
An obvious faux pas. Whenever venturing into the "grandparent" or "grandchild" realm (more than one degree of seperation), you're probably going down the wrong path.
The proper and easy approach is merely to move the method calls out to a seperate method, which one overrides in the child class like so:
public abstract class BasePage : System.Web.UI.Page, IBasePage
{
protected override void OnInit(EventArgs e)
{
// Do stuff
Method1();
Method2();
Method3();
// Call System.Web.UI.Page.OnInit
base.OnInit(e);
}
}
This works great for all my child classes/pages, but there are a few scenario's where I'd only like to call a specific set of methods, as illustrated here:It is obvious that the last base.OnInit(e) call will have the undesired effect. Being 6:23 PM, after coding all day, my fried brain's initial thought was to bypass the base class' OnInit(e) method and to call the grandparent's OnInit(e) method directly.public class MyPage: BasePage
{
protected override void OnInit(EventArgs e)
{
// Ommit Method2()
Method1();
Method3();
// This calls BasePage.OnInit, which makes
// redudant calls to Method1() and Method3(),
// and the undesired call to Method2().
base.OnInit(e);
}
}
An obvious faux pas. Whenever venturing into the "grandparent" or "grandchild" realm (more than one degree of seperation), you're probably going down the wrong path.
The proper and easy approach is merely to move the method calls out to a seperate method, which one overrides in the child class like so:
public abstract class BasePage : System.Web.UI.Page, IBasePage
{
protected override void OnInit(EventArgs e)
{
// Do stuff
Initialize();
// Call System.Web.UI.Page.OnInit
base.OnInit(e);
}
protected virtual void Initialize()
{
Method1();
Method2();
Method3();
}
}
public class MyPage: BasePage
{
protected override void Initialize()
{
// Do stuff
Method1();
Method3();
}
}
Monday, December 7, 2009
GNU Plot and SVG: Change the terminal size and font
Again, not really a dev related issue, but I did not find much info online regarding this.
When using gnuplot to create SVG files, one use the set term svg command that sets the following defaults:
One can speficy custom parameters to get the desired output:
When using gnuplot to create SVG files, one use the set term svg command that sets the following defaults:
gnuplot> set term svg
Terminal type set to 'svg'
Options are 'size 640 480 fixed fname 'Arial' fsize 12 butt '
One can speficy custom parameters to get the desired output:
gnuplot> set term svg size 640,350 fname 'Times New Roman' fsize 10
Terminal type set to 'svg'
Options are 'size 640 350 fixed fname 'Times New Roman' fsize 10 butt '
Monday, November 23, 2009
Type 'DataContract' is not defined
This error can be resolved by adding a reference to the .net System.Runtime.Serialization assemly and also importing this namespace in the file where applicable.
Also, applies to Type 'DataMember' is not defined.
Also, applies to Type 'DataMember' is not defined.
Tuesday, November 3, 2009
VB.NET: Check if an event handler has been assigned to a method
This is how one checks if an event handler (or any delegate handler for that matter) has been assigned to a method.
' Create the delegate
Public Delegate Sub UpdateEvent()
' Create a handler
Public Update As UpdateEvent
' ...
' Rest of the class
' ...
' Check if the event handler has been assigned to
If Not Update Is Nothing Then
Update()
End If
'SyncLock' operand cannot be of type '' because '' is not a reference type
Just had this little error in VB.NET:
Error Message: 'SyncLock' operand cannot be of type 'Boolean' because 'Boolean' is not a reference type.
Error ID: BC30582
I tried to change the variable to type Object, but this seems to be converted to Boolean during runtime, which raises the same error.
A clumsy way around this is to simply use a Boolean array of length 1. There must be a better way though, and I'll update this post when I find a better approach.
Yes, I did say vb. Yes, I am ashamed. Client's request.
Update:
Ok here's the deal on using SyncLock or Monitor.Enter (mutex) with value types such as Boolean, Integer, or Double. One is not supposed to lock value types, as they do not have the necessary overhead fields (MethodTablePointer and SyncBlockIndex) to allow a lock to be acquired. One gets around this issue, by creating a reference type, which acts as a flag when the value type is being written to. More on this at the end of Jeffery Richter's article on Safe Thread Synchronization.
Error Message: 'SyncLock' operand cannot be of type 'Boolean' because 'Boolean' is not a reference type.
Error ID: BC30582
I tried to change the variable to type Object, but this seems to be converted to Boolean during runtime, which raises the same error.
A clumsy way around this is to simply use a Boolean array of length 1. There must be a better way though, and I'll update this post when I find a better approach.
Yes, I did say vb. Yes, I am ashamed. Client's request.
Update:
Ok here's the deal on using SyncLock or Monitor.Enter (mutex) with value types such as Boolean, Integer, or Double. One is not supposed to lock value types, as they do not have the necessary overhead fields (MethodTablePointer and SyncBlockIndex) to allow a lock to be acquired. One gets around this issue, by creating a reference type, which acts as a flag when the value type is being written to. More on this at the end of Jeffery Richter's article on Safe Thread Synchronization.
Friday, October 23, 2009
An error occurred while reading the app.config file
I edited my app.config file manually, which did not seem to agree with VS. Even though the XML was valid, I received the message: An error occurred while reading the app.config file. The file might be corrupted or contain invalid XML. Despite this message the code will still run, but its just annoying.
This is a known bug, which I managed to get rid off by removing the project from the solution, restarting Visual Studio and adding the project again.
This is a known bug, which I managed to get rid off by removing the project from the solution, restarting Visual Studio and adding the project again.
Thursday, October 22, 2009
SQL Server: Automated log file maintenance
Ok you've all seen it before. You remote desktop onto a client's sql server to upload your app, when your upload fails due to a lack of disk space. Darnit! So you have to reduce the LDF's, which has grown to be several GBs large.
The following little script will reduce all the non-system db's log files. One can also schedule this script as a job that automatically reduces the log files. (Disclaimer: Read-up on the function log files fulfil before simply using this script. I would not recommend running this on critical production systems.)
The following little script will reduce all the non-system db's log files. One can also schedule this script as a job that automatically reduces the log files. (Disclaimer: Read-up on the function log files fulfil before simply using this script. I would not recommend running this on critical production systems.)
-- This gets us all on the same page
use [master]
-- Define some variables
declare @statement varchar(2000)
declare @dbname sysname
declare dbname_cursor cursor for
-- Select all non-system db's
select [name] from master.dbo.sysdatabases where
[name] <> 'master' and
[name] <> 'model' and
[name] <> 'msdb' and
[name] <> 'tempdb'
-- Iterate through each db record
open dbname_cursor
fetch next from dbname_cursor into @dbname
while @@fetch_status <> -1
begin
select @statement = ''
select @statement = @statement + 'use ' + @dbname + '; '
-- Backup db by runcating only (will not reduce physical file size)
select @statement = @statement + 'backup log ' + @dbname + ' with truncate_only; '
-- Get the db log file name
select @statement = @statement + 'declare @log_file varchar(2000); '
select @statement = @statement + 'select @log_file = [name] from sys.database_files where type_desc = ''LOG''; '
-- Reduce the physical file size
select @statement = @statement + 'exec(''dbcc shrinkfile ('' + @log_file + '', 0)''); '
exec(@statement)
fetch next from dbname_cursor into @dbname
end
close dbname_cursor
deallocate dbname_cursor
Wednesday, April 29, 2009
g++ 4.3 more strict with declarations
I've been moving a bunch of old C++ code over to g++ 4.3 and have found that gcc is now more strict on declarations and I often receive these sorts of errors:
error: ‘memset’ was not declared in this scope
error: ‘strncmp’ was not declared in this scope
I'm going to continually update this look-up table, which will explain what to do when receiving any of these errors:| Error | Resolution |
|---|---|
| error: ‘memset’ was not declared in this scope | Add #include <cstring> |
error: ‘strncmp’ was not declared in this scope |
Tuesday, April 21, 2009
C++: Increasing void pointer position
I became better friends with C++ today, but somehow I don't think this relationship is going anywhere.
Managed to crack this little stupid nut though. If you have a void pointer (dynamic array) you can increase it as follows:
Managed to crack this little stupid nut though. If you have a void pointer (dynamic array) you can increase it as follows:
void* ptr; // Say of type char
(*(char*)ptr) += 100; // Or any integer
Monday, April 20, 2009
Ossim on Ubuntu causes error on missing llampi++
When compiling Ossim with lam mpi on Ubuntu 9, you might receive this error:
/usr/bin/ld: cannot find -llammpi++
The easiest way to fix this is to ensure liblam4 and openmpi is installed (via the Synaptic Package Manager) and to edit the Makefile.common in the ossim directory ($OSSIM_HOME), changing the MPI_LIB_PATH.# Open the Makefile.common
gedit $OSSIM_HOME/Makefile.common
# Locate the following line and set its path to/usr/lib/lam/libMPI_LIB_PATH = -L/usr/lib/lam/lib
Compile GDAL with GeoTiff support
I've been running Ubuntu on my personal machine for a while now and just realized that the gdal synaptic package does not enable support for GeoTiffs. This is where Gentoo has one up, but its not the end of the world. You can 'simply' build GDAL from source with the correct flags.
Here's what I did:
1. Install the Tiff, GeotTiff, Png and OpenJpeg dev packages and their dependencies (libtiff4-dev, libgeotiff-dev, libpng12-dev and libopenjpeg-dev). Also be sure to install g++ and subversion.
2. Fire up a terminal and checkout the GDAL subversion repository anywhere in your home directory:
Here's what I did:
1. Install the Tiff, GeotTiff, Png and OpenJpeg dev packages and their dependencies (libtiff4-dev, libgeotiff-dev, libpng12-dev and libopenjpeg-dev). Also be sure to install g++ and subversion.
2. Fire up a terminal and checkout the GDAL subversion repository anywhere in your home directory:
svn co http://svn.osgeo.org/gdal/trunk/gdal
3. Go into the GDAL directory and run configure:cd gdal
./configure --with-geotiff=/usr --with-jpeg=/usr --with-libtiff=/usr --without-libtool
4. In theory you should be able to run make now, but the configure script missed the geotiff header files directory so I had to set these manually. This is the error I received:make -C gtiff install-obj
make[2]: Entering directory `/home/andreh/workspace/project-ossim_dev/gdal/frmts/gtiff'
/bin/sh /home/andreh/workspace/project-ossim_dev/gdal/libtool --mode=compile --tag=CXX g++ -g -O2 -Wall -I/home/andreh/workspace/project-ossim_dev/gdal/port -I/home/andreh/workspace/project-ossim_dev/gdal/gcore -I/home/andreh/workspace/project-ossim_dev/gdal/alg -I/home/andreh/workspace/project-ossim_dev/gdal/ogr -I/home/andreh/workspace/project-ossim_dev/gdal/ogr/ogrsf_frmts -DOGR_ENABLED -I/home/andreh/workspace/project-ossim_dev/gdal/port -I/usr/lib/include -I -I/include -c -o ../o/geotiff.lo geotiff.cpp
libtool: compile: g++ -g -O2 -Wall -I/home/andreh/workspace/project-ossim_dev/gdal/port -I/home/andreh/workspace/project-ossim_dev/gdal/gcore -I/home/andreh/workspace/project-ossim_dev/gdal/alg -I/home/andreh/workspace/project-ossim_dev/gdal/ogr -I/home/andreh/workspace/project-ossim_dev/gdal/ogr/ogrsf_frmts -DOGR_ENABLED -I/home/andreh/workspace/project-ossim_dev/gdal/port -I/usr/lib/include -I -I/include -c geotiff.cpp -fPIC -DPIC -o ../o/.libs/geotiff.o
geotiff.cpp:34:21: error: xtiffio.h: No such file or directory
geotiff.cpp:35:21: error: geotiff.h: No such file or directory
geotiff.cpp:36:27: error: geo_normalize.h: No such file or directory
geotiff.cpp:37:23: error: geovalues.h: No such file or directory
geotiff.cpp:46: error: 'GTIF' was not declared in this scope
geotiff.cpp:46: error: expected primary-expression before ',' token
geotiff.cpp:46: error: 'GTIFDefn' was not declared in this scope
geotiff.cpp:46: error: expected primary-expression before ')' token
geotiff.cpp:46: error: initializer expression list treated as compound expression
geotiff.cpp:47: error: 'GTIF' was not declared in this scope
geotiff.cpp:47: error: expected primary-expression before ',' token
geotiff.cpp:47: error: expected primary-expression before 'const'
geotiff.cpp:47: error: initializer expression list treated as compound expression
geotiff.cpp: In destructor 'virtual GTiffDataset::~GTiffDataset()':
geotiff.cpp:2249: error: 'XTIFFClose' was not declared in this scope
geotiff.cpp: In member function 'void GTiffDataset::WriteGeoTIFFInfo()':
geotiff.cpp:3336: error: 'TIFFTAG_GEOPIXELSCALE' was not declared in this scope
geotiff.cpp:3346: error: 'TIFFTAG_GEOTIEPOINTS' was not declared in this scope
geotiff.cpp:3363: error: 'TIFFTAG_GEOTRANSMATRIX' was not declared in this scope
geotiff.cpp:3393: error: 'TIFFTAG_GEOTIEPOINTS' was not declared in this scope
geotiff.cpp:3404: error: 'GTIF' was not declared in this scope
geotiff.cpp:3404: error: 'psGTIF' was not declared in this scope
geotiff.cpp:3413: error: 'TIFFTAG_GEOKEYDIRECTORY' was not declared in this scope
geotiff.cpp:3420: error: 'TIFFTAG_GEODOUBLEPARAMS' was not declared in this scope
geotiff.cpp:3422: error: 'TIFFTAG_GEOASCIIPARAMS' was not declared in this scope
geotiff.cpp:3425: error: 'GTIFNew' was not declared in this scope
geotiff.cpp:3428: error: 'GTIFSetFromOGISDefn' cannot be used as a function
geotiff.cpp:3434: error: 'GTRasterTypeGeoKey' was not declared in this scope
geotiff.cpp:3434: error: 'TYPE_SHORT' was not declared in this scope
geotiff.cpp:3435: error: 'RasterPixelIsPoint' was not declared in this scope
geotiff.cpp:3435: error: 'GTIFKeySet' was not declared in this scope
geotiff.cpp:3438: error: 'GTIFWriteKeys' was not declared in this scope
geotiff.cpp:3439: error: 'GTIFFree' was not declared in this scope
geotiff.cpp: In static member function 'static GDALDataset* GTiffDataset::OpenDir(GDALOpenInfo*)':
geotiff.cpp:4285: error: 'XTIFFClose' was not declared in this scope
geotiff.cpp: In member function 'CPLErr GTiffDataset::OpenOffset(TIFF*, GTiffDataset**, toff_t, int, GDALAccess, int)':
geotiff.cpp:4640: error: 'TIFFTAG_GEOPIXELSCALE' was not declared in this scope
geotiff.cpp:4647: error: 'TIFFTAG_GEOTIEPOINTS' was not declared in this scope
geotiff.cpp:4659: error: 'TIFFTAG_GEOTRANSMATRIX' was not declared in this scope
geotiff.cpp:4700: error: 'TIFFTAG_GEOTIEPOINTS' was not declared in this scope
geotiff.cpp:4724: error: 'GTIF' was not declared in this scope
geotiff.cpp:4724: error: 'hGTIF' was not declared in this scope
geotiff.cpp:4725: error: 'GTIFDefn' was not declared in this scope
geotiff.cpp:4725: error: expected `;' before 'sGTIFDefn'
geotiff.cpp:4730: error: 'GTIFNew' was not declared in this scope
geotiff.cpp:4739: error: 'sGTIFDefn' was not declared in this scope
geotiff.cpp:4739: error: 'GTIFGetDefn' was not declared in this scope
geotiff.cpp:4741: error: 'GTIFGetOGISDefn' cannot be used as a function
geotiff.cpp:4748: error: 'GTRasterTypeGeoKey' was not declared in this scope
geotiff.cpp:4749: error: 'GTIFKeyGet' was not declared in this scope
geotiff.cpp:4751: error: 'RasterPixelIsPoint' was not declared in this scope
geotiff.cpp:4757: error: 'GTIFFree' was not declared in this scope
geotiff.cpp: In static member function 'static TIFF* GTiffDataset::CreateLL(const char*, int, int, int, GDALDataType, char**)':
geotiff.cpp:5707: error: 'XTIFFClose' was not declared in this scope
geotiff.cpp: In static member function 'static GDALDataset* GTiffDataset::CreateCopy(const char*, GDALDataset*, int, char**, int (*)(double, const char*, void*), void*)':
geotiff.cpp:6217: error: 'TIFFTAG_GEOPIXELSCALE' was not declared in this scope
geotiff.cpp:6226: error: 'TIFFTAG_GEOTIEPOINTS' was not declared in this scope
geotiff.cpp:6242: error: 'TIFFTAG_GEOTRANSMATRIX' was not declared in this scope
geotiff.cpp:6279: error: 'TIFFTAG_GEOTIEPOINTS' was not declared in this scope
geotiff.cpp:6301: error: 'GTIF' was not declared in this scope
geotiff.cpp:6301: error: 'psGTIF' was not declared in this scope
geotiff.cpp:6303: error: 'GTIFNew' was not declared in this scope
geotiff.cpp:6304: error: 'GTIFSetFromOGISDefn' cannot be used as a function
geotiff.cpp:6310: error: 'GTRasterTypeGeoKey' was not declared in this scope
geotiff.cpp:6310: error: 'TYPE_SHORT' was not declared in this scope
geotiff.cpp:6311: error: 'RasterPixelIsPoint' was not declared in this scope
geotiff.cpp:6311: error: 'GTIFKeySet' was not declared in this scope
geotiff.cpp:6314: error: 'GTIFWriteKeys' was not declared in this scope
geotiff.cpp:6315: error: 'GTIFFree' was not declared in this scope
geotiff.cpp:6325: error: 'XTIFFClose' was not declared in this scope
make[2]: *** [../o/geotiff.lo] Error 1
make[2]: Leaving directory `/home/andreh/workspace/project-ossim_dev/gdal/frmts/gtiff'
make[1]: *** [gtiff-install-obj] Error 2
make[1]: Leaving directory `/home/andreh/workspace/project-ossim_dev/gdal/frmts'
make: *** [frmts-target] Error 2
And this is how to get rid of it:# open the GDALmake.opt file with an editor
gedit GDALmake.opt
# locate the CPPFLAGS line and add the include path at the end "-I/usr/include/geotiff"
CPPFLAGS = -I$(GDAL_ROOT)/port -I/usr/lib/include -I -I/include -I/usr/include/geotiff
5. One can now run make and make install:make
sudo make install
Thursday, April 2, 2009
Limited Linq to Sql
I've been playing around (ie pulling my hair out) in my spare time over the last few weeks, trying to make Linq more loosely coupled with a UI and to extend its capabilities to allow for many-to-many table updates. I find it completely rediculous how intricate Ms has made all of this. Perhaps I'm missing the plot, but unless you're trying to do some really simple little application that requires little to no flexibility on the DB side of things, STAY AWAY FROM LINQ.
I wrote my own Linq a few years ago, but decided to give Ms Linq a chance and it hasn't really been smooth sailing. The most enjoyable part of the experience was dragging my tables into the dbml window and seeing VS create all the classes for me. The rest is a friggin nightmare.
I'm not about to give up the fight though, but I'm pretty distraught at the moment.
I wrote my own Linq a few years ago, but decided to give Ms Linq a chance and it hasn't really been smooth sailing. The most enjoyable part of the experience was dragging my tables into the dbml window and seeing VS create all the classes for me. The rest is a friggin nightmare.
I'm not about to give up the fight though, but I'm pretty distraught at the moment.
Wednesday, March 11, 2009
TexnicCenter DDE Commands for Acrobat Reader
Not really a dev related post, but I had to re-install Vista due to an epic fail on MS's part. My pc went into sleep mode and wrote the files from the C:\ProgramData\Microsoft directory to the C:\ProgramData\Microso~1 dir.
If this ever happens to you, I'm sorry to say you'll have to re-install your OS. I tried everything to get the files back to where they were supposed to be, but it looks like MS tightened security on FS and its impossible to move some of the Crypto files to where they belong. Even if you boot up in Linux...
Anyhow, I have to get latex running again and I'm using TexnicCenter as an editor. I forgot the DDE commands and had to figure it out again. Joy.
Here's the basic setup:
One can also fool around with some other commands. Here's the snippet on DDE from the Adobe Interapplication Communication document:
Acrobat Application DDE Messages
This section lists all DDE messages. For complete descriptions of the parameters associated with DDE messages, see the DDE sections of the Acrobat Interapplication Communication Reference.
Application Configuration
Document Manipulation
If this ever happens to you, I'm sorry to say you'll have to re-install your OS. I tried everything to get the files back to where they were supposed to be, but it looks like MS tightened security on FS and its impossible to move some of the Crypto files to where they belong. Even if you boot up in Linux...
Anyhow, I have to get latex running again and I'm using TexnicCenter as an editor. I forgot the DDE commands and had to figure it out again. Joy.
Here's the basic setup:
- In TexnicCenter, hit Alt+F7 and click on the viewer tab.
- In the "View project output" and "Forward search" options, select the "DDE Command" radio button and fill in the following: Command = [DocOpen("%bm.pdf")][FileOpen("%bm.pdf")], Server = acroview, Topic = control
- For the "Close document before running Latex" , select DDE with the same settings as above, but change the command to be [DocClose("%bm.pdf")]
One can also fool around with some other commands. Here's the snippet on DDE from the Adobe Interapplication Communication document:
Acrobat Application DDE Messages
This section lists all DDE messages. For complete descriptions of the parameters associated with DDE messages, see the DDE sections of the Acrobat Interapplication Communication Reference.
Application Configuration
- AppExit — Exits Acrobat.
- AppHide — Iconifies or hides Acrobat.
- AppShow — Shows Acrobat.
- CloseAllDocs — Closes all open documents.
- HideToolbar — Hides the toolbar.
- MenuitemExecute — Invokes a menu item, given its language-independent name.
- ShowToolbar — Shows the toolbar.
Document Manipulation
- DocClose — Closes the file without saving it and without prompting the user to save the document if it has been modified.
- DocDeletePages — Deletes a specified range of pages in a document. It cannot delete all pages in a document.
- DocInsertPages — Inserts specified pages from one file into another.
- DocOpen — Opens a document and adds it to the list of documents known to DDE, allowing it to be manipulated by other DDE messages (for example, FileOpen).
- DocReplacePages — Replaces specified pages using pages from another file.
- DocSave — Saves the specified file.
- DocSaveAs — Saves an open file into a new file, without warning the user if there is a problem saving.
- DocSetViewMode — Controls whether bookmarks or thumbnail images are shown in addition to the document content.
- FileOpen — Opens and displays a file, making it the current document and bringing it to the front if it is already open.
- FileOpenEx — Opens and displays a file, making it the current document and bringing it to the front if it is already open. The file is opened during an idle loop to allow DDE messages to continue flowing during the opening of large documents.
- DocPrint — Prints a specified range of pages from a document, without displaying a modal Print dialog box to the user.
- FilePrint — Prints all pages in a document, displaying a modal Print dialog box to the user.
- FilePrintEx — Prints all pages in a document, displaying a modal Print dialog box to the user. Only PostScript Level 1 operators are used for PostScript printing. Printing is performed during an idle loop to allow DDE messages to continue flowing during the printing of large documents.
- FilePrintSilent — Prints all pages in a document, displaying no print dialog box to the user.
- FilePrintSilentEx — Prints all pages in a document, displaying no print dialog box to the user. Only PostScript Level 1 operators are used for PostScript printing. Printing is performed during an idle loop to allow DDE messages to continue flowing during the printing of large documents.
- FilePrintTo — Prints all pages in a document to a specified printer, using a specified driver and port, displaying a modal Print dialog box to the user.
- FilePrintToEx — Prints all pages in a document to a specified printer, using a specified driver and port, displaying a modal Print dialog box to the user. Only PostScript Level 1 operators are used for PostScript printing. Printing is performed during an idle loop to allow DDE messages to continue flowing during the printing of large documents.
- DocGoTo — Goes to the specified page.
- DocGoToNameDest — Goes to the specified name destination within the document.
- DocPageDown — Scrolls forward through the document by one screen area.
- DocPageLeft — Scrolls to the left by a small amount.
- DocPageRight — Scrolls to the right by a small amount.
- DocPageUp — Scrolls backward through the document by one screen area.
- DocScrollTo — Scrolls the view of the current page to a specified location.
- DocZoomTo — Sets the zoom for a specified document.
- DocFind — Finds a string in a specified file.
Subscribe to:
Posts (Atom)