Geographic Information Systems Asked by Carlos Alberto Rojas Casique on July 27, 2021
I have this code in Java:
conn = DriverManager.getConnection ("jdbc: postgresql: // localhost: 5432 / postgis_23_sample" "postgres", "admin");
conn.setAutoCommit (false);
String s = "SELECT ST_AsRaster (ST_Buffer (ST_GeomFromText ('LINESTRING (50 50,150 150,150 50)'), 10), 200,200, ARRAY ['8BUI' '8BUI' '8BUI'] ARRAY [118,154,118] ARRAY [0 , 0,0]) ";
PreparedStatement sGetImg = conn.prepareStatement (s);
SGetImg.executeQuery ResultSet rs = ();
FileOutputStream fout;
try
{
rs.next ();
fout = new FileOutputStream (new File ("d: files save1x.png"));
fout.write (rs.getBytes (1));
fout.close ();
}
catch (Exception e)
{
System.out.println ("Can not create file");
e.printStackTrace ();
}
rs.close ();
sGetImg.close ();
conn.close ();
catch (SQLException se)
{
System.out.println ("Could not connect: print out a stack trace and exit.");
se.printStackTrace ();
System.exit (1);
}
....
I created the file but apparently the PNG file is corrupt, you can not open. That I can be doing wrong.
I reviewed the bytes and the query returns the array of bytes me, but does not write the file apparently well.
Postgres 9.4 y PosGis 2.2
Based on my reading of the documentation shouldn't your query be
SELECT ST_AsPNG(ST_AsRaster (ST_Buffer (ST_GeomFromText ('LINESTRING (50 50,150 150,150 50)'), 10), 200,200, ARRAY ['8BUI' '8BUI' '8BUI'] ARRAY [118,154,118] ARRAY [0 , 0,0]));
Answered by Ian Turton on July 27, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP